/** * Sets the width of the usage output. * @param usageWidth the width of the usage output in columns. * @throws IllegalArgumentException if {@code usageWidth} is negative * @deprecated * Use {@link ParserProperties#withUsageWidth(int)} instead. */ public void setUsageWidth(int usageWidth) { parserProperties.withUsageWidth(usageWidth); }
/** * Sets the width of the usage output. * @param usageWidth the width of the usage output in columns. * @throws IllegalArgumentException if {@code usageWidth} is negative * @deprecated * Use {@link ParserProperties#withUsageWidth(int)} instead. */ public void setUsageWidth(int usageWidth) { parserProperties.withUsageWidth(usageWidth); }
private void printUsage(Object options) { CmdLineParser parser = new CmdLineParser(options); StringWriter sw = new StringWriter(); sw.append(USAGE_PREFIX + "\n"); sw.append(ALT_USAGE_PREFIX + " <source> <destination>\n"); sw.append(ALT_USAGE_PREFIX + " [OPTION]... [<value>...]\n\n"); sw.append("Options:"); System.out.println(sw.toString()); parser.getProperties().withUsageWidth(100); parser.printUsage(System.out); }
/** * Sets the width of the usage output. * @param usageWidth the width of the usage output in columns. * @throws IllegalArgumentException if {@code usageWidth} is negative * @deprecated * Use {@link ParserProperties#withUsageWidth(int)} instead. */ public void setUsageWidth(int usageWidth) { parserProperties.withUsageWidth(usageWidth); }
/** * Sets the width of the usage output. * @param usageWidth the width of the usage output in columns. * @throws IllegalArgumentException if {@code usageWidth} is negative * @deprecated * Use {@link ParserProperties#withUsageWidth(int)} instead. */ public void setUsageWidth(int usageWidth) { parserProperties.withUsageWidth(usageWidth); }
private void printUsage(Object options) { CmdLineParser parser = new CmdLineParser(options); StringWriter sw = new StringWriter(); sw.append(USAGE_PREFIX + "\n"); sw.append(ALT_USAGE_PREFIX + " <source> <destination>\n"); sw.append(ALT_USAGE_PREFIX + " [OPTION]... [<value>...]\n\n"); sw.append("Options:"); System.out.println(sw.toString()); parser.getProperties().withUsageWidth(100); parser.printUsage(System.out); }
public ArgsUtil(AppAbortStrategy strategy, BasicOptions opts) { this.abortStrategy = strategy; this.opts = opts; this.parser = new CmdLineParser(opts); try { parser.getProperties() .withUsageWidth(Integer.parseInt(System.getenv("COLUMNS"))); } catch (Exception e) { parser.getProperties().withUsageWidth(120); } }
public ArgsUtil(AppAbortStrategy strategy, BasicOptions opts) { this.abortStrategy = strategy; this.opts = opts; this.parser = new CmdLineParser(opts); try { parser.getProperties() .withUsageWidth(Integer.parseInt(System.getenv("COLUMNS"))); } catch (Exception e) { parser.getProperties().withUsageWidth(120); } }
private CmdLineParser getParser() { if (parser == null) { final ParserProperties properties = ParserProperties.defaults(); properties.withUsageWidth(80); parser = new CmdLineParser(this, properties); } return parser; }
public static void printUsage(CmdLineParser parser, OptionHandlerFilter filter, PrintStream out) { parser.getProperties().withUsageWidth(USAGE_WIDTH); parser.printUsage(new OutputStreamWriter(out), null, filter); }
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[] 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); } }