/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean) { // for display purposes, we like the arguments in argument order, but the options in alphabetical order this(bean, ParserProperties.defaults()); }
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean) { // for display purposes, we like the arguments in argument order, but the options in alphabetical order this(bean, ParserProperties.defaults()); }
/** * Get string representing usage for this option, of the form "name metaval", * e.g. "-foo VALUE" or "--foo VALUE" * @param rb ResourceBundle to get localized version of meta string */ public final String getNameAndMeta(ResourceBundle rb) { return getNameAndMeta(rb, ParserProperties.defaults()); }
/** * Get string representing usage for this option, of the form "name metaval", * e.g. "-foo VALUE" or "--foo VALUE" * @param rb ResourceBundle to get localized version of meta string */ public final String getNameAndMeta(ResourceBundle rb) { return getNameAndMeta(rb, ParserProperties.defaults()); }
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean) { // for display purposes, we like the arguments in argument order, but the options in alphabetical order this(bean, ParserProperties.defaults()); }
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean) { // for display purposes, we like the arguments in argument order, but the options in alphabetical order this(bean, ParserProperties.defaults()); }
/** * Get string representing usage for this option, of the form "name metaval", * e.g. "-foo VALUE" or "--foo VALUE" * @param rb ResourceBundle to get localized version of meta string */ public final String getNameAndMeta(ResourceBundle rb) { return getNameAndMeta(rb, ParserProperties.defaults()); }
/** * Get string representing usage for this option, of the form "name metaval", * e.g. "-foo VALUE" or "--foo VALUE" * @param rb ResourceBundle to get localized version of meta string */ public final String getNameAndMeta(ResourceBundle rb) { return getNameAndMeta(rb, ParserProperties.defaults()); }
private CmdLineParser getParser() { if (parser == null) { final ParserProperties properties = ParserProperties.defaults(); properties.withUsageWidth(80); parser = new CmdLineParser(this, properties); } return parser; }
protected CmdLineParser createParser(Args args) { return new CmdLineParser(args, ParserProperties.defaults().withUsageWidth(120)); }
public ConverterOptions() { String columns = System.getProperty("columns", System.getenv("COLUMNS")); helpWidth = (columns != null && columns.matches("\\d+")) ? Integer.parseInt(columns) : DefaultConfig.HELP_WIDTH; ParserProperties props = ParserProperties.defaults() .withOptionSorter(null) .withUsageWidth(helpWidth) .withShowDefaults(false); parser = new CmdLineParser(this, props); }
public CommandLineArguments() { parser = new CmdLineParser(this, ParserProperties.defaults().withShowDefaults(true).withUsageWidth(80)); }
/** * @param args : arguments / options. * @return The command line parser. * @throws CmdLineException If an error occurs while parsing the options. */ public CmdLineParser parseOptions(final String... args) throws CmdLineException { final CmdLineParser parser = new CmdLineParser(this); ParserProperties.defaults().withUsageWidth(150); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(); System.err.println("======> " + e.getMessage()); System.err.println(); printUsage(parser); throw e; } return parser; }
/** * Constructor. * * @param args command line arguments. */ public DefaultConfig(String... args) { String columns = System.getProperty("columns", System.getenv("COLUMNS")); helpWidth = (columns != null && columns.matches("\\d+")) ? Integer.parseInt(columns) : HELP_WIDTH; ParserProperties props = ParserProperties.defaults() .withOptionSorter(null) .withUsageWidth(helpWidth) .withShowDefaults(false); parser = new CmdLineParser(this, props); if (args.length > 0) parseCommandLine(args); }
public static void main(String[] argv) throws IOException { Args args = new Args(); CmdLineParser parser = new CmdLineParser(args, ParserProperties.defaults().withUsageWidth(100)); try { parser.parseArgument(argv); } catch (CmdLineException e) { System.err.println(e.getMessage()); parser.printUsage(System.err); System.exit(1); } if (args.collection.endsWith(".gz")) { System.out.println("gzipped collection is not seekable: use compressed version!"); System.exit(-1); } Configuration config = new Configuration(); FileSystem fs = FileSystem.get(config); MapFile.Reader reader = new MapFile.Reader(new Path(args.index + "/part-r-00000"), config); lookupTerm(args.term, reader, args.collection, fs); reader.close(); }
public static void main(String[] args) throws Exception { Args indexArgs = new Args(); CmdLineParser parser = new CmdLineParser(indexArgs, ParserProperties.defaults().withUsageWidth(90)); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); parser.printUsage(System.err); System.err.println("Example: "+ IndexFreebase.class.getSimpleName() + parser.printExample(OptionHandlerFilter.REQUIRED)); return; } new IndexFreebase(indexArgs.input, indexArgs.index, indexArgs.storeTriples, indexArgs.langEnOnly).run(); }
public static void main(String[] args) throws Exception { IndexCollection.Args indexCollectionArgs = new IndexCollection.Args(); CmdLineParser parser = new CmdLineParser(indexCollectionArgs, ParserProperties.defaults().withUsageWidth(90)); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); parser.printUsage(System.err); System.err.println("Example: " + IndexCollection.class.getSimpleName() + parser.printExample(OptionHandlerFilter.REQUIRED)); return; } new IndexCollection(indexCollectionArgs).run(); } }
public static void main(String[] args) throws Exception { Args mapCollectionArgs = new Args(); CmdLineParser parser = new CmdLineParser(mapCollectionArgs, ParserProperties.defaults().withUsageWidth(90)); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); parser.printUsage(System.err); System.err.println("Example: "+ MapCollections.class.getSimpleName() + parser.printExample(OptionHandlerFilter.REQUIRED)); return; } new MapCollections(mapCollectionArgs).run(); } }
public static void main(String[] args) throws Exception { SearchArgs searchArgs = new SearchArgs(); CmdLineParser parser = new CmdLineParser(searchArgs, ParserProperties.defaults().withUsageWidth(90)); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); parser.printUsage(System.err); System.err.println("Example: SearchCollection" + parser.printExample(OptionHandlerFilter.REQUIRED)); return; } final long start = System.nanoTime(); SearchCollection searcher = new SearchCollection(searchArgs); searcher.runTopics(); searcher.close(); final long durationMillis = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS); LOG.info("Total run time: " + DurationFormatUtils.formatDuration(durationMillis, "HH:mm:ss")); } }
public static void main(String[] args) { Starter starter = new Starter(); CmdLineParser parser = new CmdLineParser(starter, ParserProperties.defaults().withUsageWidth(120)); try { parser.parseArgument(args); if (starter.cmd == null) { // no command specified, we have to use StarterCommand starter.cmd = starter; } starter.cmd.run(parser); } catch (CmdLineException e) { starter.LOG.error(e.getMessage()); starter.LOG.error(""); starter.cmd.printUsage(); System.exit(1); } catch (CmdRunException ex) { handleException(ex, starter.LOG); System.exit(2); } catch (Exception e) { handleException(e, starter.LOG); System.exit(3); } }