List of usage examples for org.apache.commons.cli OptionBuilder withDescription
public static OptionBuilder withDescription(String newDescription)
From source file:mitm.application.djigzo.tools.ProxyManager.java
@SuppressWarnings("static-access") private Options createCommandLineOptions() { Options options = new Options(); Option getOption = OptionBuilder.create("get"); getOption.setRequired(false);/* ww w . ja va 2s. c om*/ getOption.setDescription("Returns the proxy settings"); options.addOption(getOption); Option userOption = OptionBuilder.withArgName("user").hasArg().withDescription("user").create("user"); userOption.setRequired(false); options.addOption(userOption); Option passwordOption = OptionBuilder.withArgName("password").hasArg().withDescription("password") .create("password"); passwordOption.setRequired(false); options.addOption(passwordOption); Option passwordPromptOption = OptionBuilder.withDescription("ask for password").create("pwd"); passwordPromptOption.setRequired(false); options.addOption(passwordPromptOption); Option helpOption = OptionBuilder.withDescription("Show help").create("help"); helpOption.setRequired(false); options.addOption(helpOption); hostOption = OptionBuilder.withArgName("host").hasArg() .withDescription("The host to connect to (127.0.0.1)").create("host"); options.addOption(hostOption); portOption = OptionBuilder.withArgName("port").hasArg() .withDescription("The port to use (" + DjigzoWSDefaults.PORT + ")").create("port"); options.addOption(portOption); return options; }
From source file:com.aliyun.openservices.odps.console.commands.logview.GetLogAction.java
@SuppressWarnings("static-access") protected Options getOptions() { Options options = super.getOptions(); options.addOption(OptionBuilder.withDescription("stdout or stderr").withArgName("log type").hasArg() .withLongOpt("type").create("T")); options.addOption(OptionBuilder.withDescription("print last <size> bytes of log, default is 8KB") .withArgName("size").hasArg().create('s')); return options; }
From source file:com.boundary.plugin.sdk.jmx.ExportMBeans.java
@SuppressWarnings("static-access") private void buildOptions() { helpOption = OptionBuilder.withDescription("Display help information").withLongOpt("help").create("?"); hostOption = OptionBuilder.withArgName("host").hasArgs(1).isRequired().withDescription("JMX host") .withLongOpt("host").create("h"); portOption = OptionBuilder.withArgName("port").hasArgs(1).isRequired().withDescription("JMX port") .withLongOpt("port").create("p"); exportOption = OptionBuilder.withArgName("type").hasArgs(1).withDescription( "Selects what to export which is either: mbeans, metrics, or plugins." + " defaults to mbeans") .withLongOpt("export").create("e"); mergeFileOption = OptionBuilder.withArgName("metric-definitions.json").hasArgs(1) .withDescription("Metrics definition file to merge into exported metric definitions." + "Used to override previously specified values. Uses the metric identifer" + " as the key.") .withLongOpt("merge-file").create("m"); outputFileOption = OptionBuilder.withArgName("path").hasArgs(1) .withDescription("Path to output the exported json file").create("f"); prefixOption = OptionBuilder.withArgName("prefix").hasArgs(1) .withDescription("Prefix to add to metric display names. Defaults to empty").create("x"); options.addOption(helpOption);/*from w w w. j av a2 s.co m*/ options.addOption(hostOption); options.addOption(portOption); options.addOption(exportOption); options.addOption(mergeFileOption); options.addOption(outputFileOption); options.addOption(prefixOption); }
From source file:com.google.code.linkedinapi.client.examples.ProfileApiExample.java
/** * Build command line options object./*from w ww . ja v a 2 s.c o m*/ */ private static Options buildOptions() { Options opts = new Options(); String helpMsg = "Print this message."; Option help = new Option(HELP_OPTION, helpMsg); opts.addOption(help); String consumerKeyMsg = "You API Consumer Key."; OptionBuilder.withArgName("consumerKey"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerKeyMsg); Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION); opts.addOption(consumerKey); String consumerSecretMsg = "You API Consumer Secret."; OptionBuilder.withArgName("consumerSecret"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerSecretMsg); Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION); opts.addOption(consumerSecret); String accessTokenMsg = "You OAuth Access Token."; OptionBuilder.withArgName("accessToken"); OptionBuilder.hasArg(); OptionBuilder.withDescription(accessTokenMsg); Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION); opts.addOption(accessToken); String tokenSecretMsg = "You OAuth Access Token Secret."; OptionBuilder.withArgName("accessTokenSecret"); OptionBuilder.hasArg(); OptionBuilder.withDescription(tokenSecretMsg); Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION); opts.addOption(accessTokenSecret); String idMsg = "ID of the user whose profile is to be fetched."; OptionBuilder.withArgName("id"); OptionBuilder.hasArg(); OptionBuilder.withDescription(idMsg); Option id = OptionBuilder.create(ID_OPTION); opts.addOption(id); String urlMsg = "Profile URL of the user whose profile is to be fetched."; OptionBuilder.withArgName("url"); OptionBuilder.hasArg(); OptionBuilder.withDescription(urlMsg); Option url = OptionBuilder.create(URL_OPTION); opts.addOption(url); String typeMsg = "Type of profile. Either standard or public."; OptionBuilder.withArgName("type"); OptionBuilder.hasArg(); OptionBuilder.withDescription(typeMsg); Option type = OptionBuilder.create(TYPE_OPTION); opts.addOption(type); return opts; }
From source file:mitm.common.tools.PfxTool.java
@SuppressWarnings("static-access") private Options createCommandLineOptions() { Options options = new Options(); inPasswordOption = OptionBuilder.withArgName("inpass").hasArg() .withDescription("Password for the input pfx.").create("inpass"); inPasswordOption.setRequired(true);/*from ww w . ja v a2 s .co m*/ options.addOption(inPasswordOption); destPasswordOption = OptionBuilder.withArgName("destpass").hasArg() .withDescription("Password for the destination pfx.").create("destpass"); destPasswordOption.setRequired(false); options.addOption(destPasswordOption); inOption = OptionBuilder.withArgName("file").hasArg().withDescription("The filename of the input pfx.") .create("in"); inOption.setRequired(true); options.addOption(inOption); destOption = OptionBuilder.withArgName("file").hasArg() .withDescription("The filename of the destination pfx.").create("dest"); destOption.setRequired(false); options.addOption(destOption); mergeOption = OptionBuilder.withDescription("Adds the input pfx to the output pfx.").create("merge"); mergeOption.setRequired(false); options.addOption(mergeOption); listOption = OptionBuilder.withDescription("Shows all items from the input pfx.").create("list"); listOption.setRequired(false); options.addOption(listOption); helpOption = OptionBuilder.withDescription("Show help").create("help"); helpOption.setRequired(false); options.addOption(helpOption); retainAliasesOption = OptionBuilder.withDescription("If enabled, the aliases from the input will be kept.") .create("retainaliases"); retainAliasesOption.setRequired(false); options.addOption(retainAliasesOption); return options; }
From source file:com.google.code.linkedinapi.client.examples.CompaniesApiExample.java
/** * Build command line options object.//from www .j a v a 2s .c o m */ private static Options buildOptions() { Options opts = new Options(); String helpMsg = "Print this message."; Option help = new Option(HELP_OPTION, helpMsg); opts.addOption(help); String consumerKeyMsg = "You API Consumer Key."; OptionBuilder.withArgName("consumerKey"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerKeyMsg); Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION); opts.addOption(consumerKey); String consumerSecretMsg = "You API Consumer Secret."; OptionBuilder.withArgName("consumerSecret"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerSecretMsg); Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION); opts.addOption(consumerSecret); String accessTokenMsg = "You OAuth Access Token."; OptionBuilder.withArgName("accessToken"); OptionBuilder.hasArg(); OptionBuilder.withDescription(accessTokenMsg); Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION); opts.addOption(accessToken); String tokenSecretMsg = "You OAuth Access Token Secret."; OptionBuilder.withArgName("accessTokenSecret"); OptionBuilder.hasArg(); OptionBuilder.withDescription(tokenSecretMsg); Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION); opts.addOption(accessTokenSecret); String idMsg = "ID of the user whose profile is to be fetched."; OptionBuilder.withArgName("id"); OptionBuilder.hasArg(); OptionBuilder.withDescription(idMsg); Option id = OptionBuilder.create(ID_OPTION); opts.addOption(id); return opts; }
From source file:acromusashi.kafka.log.producer.LinuxApacheLogProducer.java
/** * ???/*from w w w . j av a 2 s .co m*/ * * @return ?? */ public static Options createOptions() { Options cliOptions = new Options(); // OptionBuilder.hasArg(true); OptionBuilder.withArgName("LinuxApacheLogProducer Conf Path"); OptionBuilder.withDescription("LinuxApacheLogProducer Conf Path"); OptionBuilder.isRequired(true); Option confPathOption = OptionBuilder.create("c"); // OptionBuilder.withDescription("show help"); Option helpOption = OptionBuilder.create("h"); cliOptions.addOption(confPathOption); cliOptions.addOption(helpOption); return cliOptions; }
From source file:com.archivas.clienttools.arcmover.cli.ArcJobMgr.java
private void addOption(Options options, JobMgrAction action) { if (action.getArgName() != null) { options.addOption(OptionBuilder.hasOptionalArg().withArgName(action.getArgName()) .withDescription(action.getDescription()).withLongOpt(action.getCmdLineLongOpt()) .create(action.getCmdLineShortOpt())); } else {//www. jav a2 s . c om options.addOption(OptionBuilder.withDescription(action.getDescription()) .withLongOpt(action.getCmdLineLongOpt()).create(action.getCmdLineShortOpt())); } }
From source file:edu.uchicago.lowasser.flaginjection.Flags.java
public static Injector bootstrapFlagInjector(final String[] args, String mainClassName, List<String> packages, Module... baseModules) {/*from ww w . j a va2 s . c om*/ Logger logger = Logger.getLogger("org.learningu.scheduling.flags.Flags"); AbstractModule linkingModule = new AbstractModule() { @Override protected void configure() { } @Provides @RuntimeArguments String[] commandLineArguments() { return args; } @Provides @Singleton Options options(Map<Flag, Type> flagsMap) { Options options = new Options(); for (Flag flag : flagsMap.keySet()) { OptionBuilder.hasArgs(); OptionBuilder.withLongOpt(flag.name()); OptionBuilder.withDescription(flag.description()); OptionBuilder.withArgName(flagsMap.get(flag).toString()); options.addOption(OptionBuilder.create()); } return options; } @Provides @Singleton CommandLine commandLine(Options options, @RuntimeArguments String[] args) { try { return new PosixParser().parse(options, args); } catch (ParseException e) { throw Throwables.propagate(e); } } }; logger.fine("Built Options module"); Injector baseInjector = Guice.createInjector(new FlagErrorModule(mainClassName), Modules.combine(Iterables.concat(Arrays.asList(baseModules), ImmutableList.of(linkingModule)))); logger.fine("Bootstrapping flag injector with command line arguments"); Injector createdInjector = baseInjector .createChildInjector(baseInjector.getInstance(FlagBootstrapModule.class)); // Use reflection to instantiate the variables in FlagClass classes for (String packageName : packages) { Reflections reflections = new Reflections(packageName); Set<Class<? extends FlagsClass>> classes = reflections.getSubTypesOf(FlagsClass.class); for (Class<? extends FlagsClass> flagClass : classes) { createdInjector.getInstance(flagClass); } } return createdInjector; }
From source file:fusejext2.FuseJExt2.java
@SuppressWarnings("static-access") private static void initializeCommandLineParser() { parser = new PosixParser(); options = new Options(); options.addOption(OptionBuilder .withDescription(// ww w . jav a 2 s . co m "Activate daemon mode in jext2. Don't use directly, " + "use jext2_daemon.sh instead") .withLongOpt("daemon").create("D")); options.addOption(OptionBuilder.withDescription("Print usage").withLongOpt("help").create("h")); options.addOption(OptionBuilder.withDescription("Options forwarded to FUSE").withLongOpt("fuse-options") .withType(new String("")).hasArg().withArgName("FUSE_OPTIONS").create("o")); options.addOption(OptionBuilder.withDescription("Charset for file system string conversion") .withLongOpt("charset").withType(new String("")).hasArg().withArgName("CHARSET").create("c")); options.addOption(OptionBuilder.withDescription("Log to file, ").withLongOpt("log").withType(new String("")) .hasArg().withArgName("FILENAME").create("l")); options.addOption(OptionBuilder .withDescription("Number of threads to execute jext2 tasks. Default: #CPU + 1") .withLongOpt("threads").withType(new Integer(0)).hasArg().withArgName("NTHREADS").create("n")); options.addOption(OptionBuilder .withDescription( "Length of the queue the executer uses to schedule tasks from. Default: " + queueLength) .withType(new Integer(0)).withLongOpt("queue-length").hasArg().withArgName("QUEUE_LENGTH") .create("Q")); options.addOption(OptionBuilder.withDescription("Periodically log executor status (Loglevel INFO)") .withLongOpt("log-executor").withType(new Integer(0)).hasArg().withArgName("TIME_IN_MILLIS") .create("E")); options.addOption(OptionBuilder .withDescription( "Debug output, possible values:\n" + "SEVERE (highest value)\n" + "WARNING\n" + "INFO\n" + "CONFIG\n" + "FINE\n" + "FINER\n" + "FINEST (lowest value)\n" + "Default: FINE") .hasOptionalArg().withArgName("LEVEL").withLongOpt("debug").create("d")); options.addOption(OptionBuilder.withDescription("Verbose output (same as --debug INFO)") .withLongOpt("verbose").create("v")); }