當前位置: 首頁>>代碼示例>>Java>>正文


Java JCommander.usage方法代碼示例

本文整理匯總了Java中com.beust.jcommander.JCommander.usage方法的典型用法代碼示例。如果您正苦於以下問題:Java JCommander.usage方法的具體用法?Java JCommander.usage怎麽用?Java JCommander.usage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.beust.jcommander.JCommander的用法示例。


在下文中一共展示了JCommander.usage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processCommandLineArguments

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
/**
 * Use JCommander to process the provided command-line arguments.
 * This method is an instance method (not static) to allow JCommander
 * to use this instance's JCommander-annotated fields.
 *
 * @param arguments Command-line arguments.
 */
private void processCommandLineArguments(final String[] arguments)
{
   final JCommander commander
      = JCommander.newBuilder()
      .programName("JCommander Demonstration")
      .addObject(this)
      .verbose(1)
      .build();
   commander.parse(arguments);
   if (help)
   {
      commander.usage();
   }
   else
   {
      out.println("The file name provided is '" + file + "' and verbosity is set to " + verbose);
   }
}
 
開發者ID:dustinmarx,項目名稱:java-cli-demos,代碼行數:26,代碼來源:Main.java

示例2: parse

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
/**
 * Parses command line arguments and populates this command line instance.
 * <p>
 * If the command line arguments include the "help" argument, or if the
 * arguments have incorrect values or order, then usage information is
 * printed to {@link System#out} and the program terminates.
 *
 * @param args
 *            the command line arguments
 * @return an instance of the parsed arguments object
 */
public Arguments parse(String[] args) {

    JCommander jCommander = new JCommander(this);
    jCommander.setProgramName("jsonschema2pojo");

    try {
        jCommander.parse(args);

        if (this.showHelp) {
            jCommander.usage();
            exit(EXIT_OKAY);
        }
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        jCommander.usage();
        exit(EXIT_ERROR);
    }

    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:Arguments.java

示例3: main

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
public static void main(String[] args) {
	Main app = new Main();

	JCommander jc = new JCommander(app);
	try {
		jc.parse(args);
	} catch (ParameterException pe) {
		System.err.println(pe.getMessage());
		jc.usage();
		return;
	}
	try {
		app.run();
	} catch (IOException e) {
		e.printStackTrace();
		jc.usage();
		return;
	}
}
 
開發者ID:georghinkel,項目名稱:ttc2017smartGrids,代碼行數:20,代碼來源:Main.java

示例4: WordSenseCLI

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
WordSenseCLI(String[] args) {
    cmd = new JCommander(this);
    cmd.setProgramName(WordSenseCLI.class.getSimpleName());
    try {
        cmd.parse(args);
        if (help || args.length == 0) {
            System.out.println(helpMessage);
            cmd.usage();
            System.exit(0);
        }
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        cmd.usage();
        System.exit(1);
    }
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:17,代碼來源:WordSenseCLI.java

示例5: init

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
@Override
public synchronized void init(DaemonContext context) {
    if (state != State.NONE) {
        throw new IllegalStateException("initialized already");
    }

    final JCommander commander = new JCommander(this);
    commander.setProgramName(getClass().getName());
    commander.parse(context.getArguments());

    if (help != null && help) {
        commander.usage();
        final DaemonController controller = context.getController();
        if (controller != null) {
            controller.fail();
        }
        return;
    }

    state = State.INITIALIZED;
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:22,代碼來源:Main.java

示例6: parse

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
public ArgumentParsingResult parse(String[] args) {
  DelimitedIngestArguments argsPojo = new DelimitedIngestArguments();
  try {
    JCommander jcommander = new JCommander(argsPojo, args);

    // If the user requested help, print it and then signal to terminate the app.
    if (argsPojo.isHelp()) {
      jcommander.usage();
      return ArgumentParsingResult.terminate(argsPojo);
    }

    return ArgumentParsingResult.successful(argsPojo);
  } catch (Exception e) {
    return ArgumentParsingResult.failed(e);
  }
}
 
開發者ID:joshelser,項目名稱:accumulo-delimited-ingest,代碼行數:17,代碼來源:ArgumentParser.java

示例7: startGatling

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
private static int startGatling(String[] args) {
    JetGatlingOptions options = new JetGatlingOptions();
    JCommander jcommander = new JCommander(options, args);

    if (args.length == 0 || options.isHelp()) {
        jcommander.usage();
        return 0;
    }

    if (!options.check()) {
        return 10;
    }

    OPTIONS = options;
    return GatlingExecutor.execute(options);
}
 
開發者ID:scw1109,項目名稱:jet-gatling,代碼行數:17,代碼來源:JetGatling.java

示例8: VerbSenseArgumentCounter

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
private VerbSenseArgumentCounter(String... args) {
    JCommander cmd = new JCommander(this);
    cmd.setProgramName(this.getClass().getSimpleName());
    try {
        if (args.length == 0) {
            cmd.usage();
            System.exit(0);
        }
        cmd.parse(args);
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        cmd.usage();
        System.exit(1);
    }
    initializeDb();
    initializeAnnotator();
    validateDir();
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:19,代碼來源:VerbSenseArgumentCounter.java

示例9: main

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    try {
        LOGGER.debug("Parsing the arguments ...");
        Configuration cfg = new Configuration();
        JCommander jcommander = new JCommander(cfg, args);

        if (cfg.isHelp()) {
            // prints out the usage help
            jcommander.usage();
            return;
        }
        
        cfg.validate();

        AbstractBulkInsertBenchmark benchmark;
        switch (cfg.getClientType()) {

        case rxNonBlocking:
            benchmark = RxAsyncBulkInsertBenchmark.fromConfiguration(cfg);
            break;
        case blocking:
            benchmark = SyncBulkInsertBenchmark.fromConfiguration(cfg);
            break;

        default:
            throw new RuntimeException(cfg.getClientType() + " is not supported");
        }

        benchmark.init();
        benchmark.run();
        benchmark.shutdown();

    } catch (ParameterException e) {
        // if any error in parsing the cmd-line options print out the usage help
        System.err.println("Invalid Usage: " + e.getMessage());
        System.err.println("Try '-help' for more information.");

        System.exit(1);
    }
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:41,代碼來源:Main.java

示例10: printUsageAndExit

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
void printUsageAndExit(int exitCode, CliArguments cliArguments) {
    StringBuilder out = new StringBuilder();

    JCommander jCommander = new JCommander(cliArguments);
    jCommander.setProgramName("java -jar " + jarName());
    jCommander.usage(out);
    System.err.println(out);
    System.exit(exitCode);
}
 
開發者ID:gocd,項目名稱:gocd-filebased-authentication-plugin,代碼行數:10,代碼來源:PasswordGenerator.java

示例11: main

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
@SuppressWarnings("checkstyle:Regexp")
public static void main(final String[] args) throws IOException
{
    final CommandLineArgs commandLineArgs = new CommandLineArgs();
    final JCommander jCommander = new JCommander(commandLineArgs);
    try
    {
        jCommander.parse(args);
    }
    catch (final ParameterException p)
    {
        printUsage(p.getJCommander());
        System.exit(1);
    }

    if (commandLineArgs.isHelp())
    {
        jCommander.usage();
        return;
    }

    final String gitHash = commandLineArgs.getGitHash();
    if (gitHash == null || gitHash.isEmpty())
    {
        System.err.println("-g (GitHash) null or empty");
        printUsage(jCommander);
        System.exit(2);
    }

    final InfluxJmhReportPublisher influxJmhReportPublisher = new InfluxJmhReportPublisher();
    final InfluxJmhReporter influxJmhReporter = new InfluxJmhReporter(influxJmhReportPublisher, new FileReader(),
                                                                      commandLineArgs.getInfluxUrl(),
                                                                      commandLineArgs.getGitHash(),
                                                                      commandLineArgs.getHostname());
    final List<String> jsonFiles = commandLineArgs.getJsonFiles();

    influxJmhReporter.reportResult(jsonFiles);
}
 
開發者ID:TransFICC,項目名稱:influx-jmh-reporter,代碼行數:39,代碼來源:InfluxJmhReporterMain.java

示例12: parse

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
public void parse(final JCommander commander) {
    if (showVersion) {
        System.out.println(getVersion());
        return;
    }
    if (showHelp) {
        commander.usage();
    }
}
 
開發者ID:Meituan-Dianping,項目名稱:walle,代碼行數:10,代碼來源:WalleCommandLine.java

示例13: OntoNotesConverter

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
private OntoNotesConverter(String... args) {
    JCommander cmd = new JCommander(this);
    cmd.setProgramName(this.getClass().getSimpleName());
    try {
        cmd.parse(args);
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        cmd.usage();
        System.exit(1);
    }
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:12,代碼來源:OntoNotesConverter.java

示例14: parse

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
public static StartupOptions parse(String[] cliArgs) {
  logger.debug("Parsing arguments.");
  StartupOptions args = new StartupOptions();
  JCommander jc = new JCommander(args, cliArgs);
  if(args.help){
    jc.usage();
    System.exit(0);
  }
  return args;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:11,代碼來源:StartupOptions.java

示例15: main

import com.beust.jcommander.JCommander; //導入方法依賴的package包/類
public static void main(String[] args) {
    Vertx vertx = Vertx.vertx();

    Args cli = new Args();
    JCommander commander = JCommander.newBuilder()
        .addObject(cli)
        .build();
    commander.parse(args);

    if (cli.help) {
        commander.usage();
        return;
    }

    WebClientOptions options = new WebClientOptions();
    String host = cli.url.getHost();
    int port = cli.url.getPort();
    if (port <= 0) {
        port = 80;
    }
    options.setDefaultHost(host);
    options.setDefaultPort(port);
    WebClient client = WebClient.create(vertx, options);

    switch (cli.action.toLowerCase()) {
        case "remove": remove(vertx, client, cli); break;
        case "add": add(vertx, client, cli); break;
        case "populate": populate(vertx, client); break;
        case "get" : list(vertx, client); break;
        default: System.out.println("Unknown action " + cli.action + ", supported actions are list, remove, add " +
            "and populate");
    }
}
 
開發者ID:cescoffier,項目名稱:vertx-openshift-shopping-hol,代碼行數:34,代碼來源:ShoppingBackendClient.java


注:本文中的com.beust.jcommander.JCommander.usage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。