当前位置: 首页>>代码示例>>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;未经允许,请勿转载。