本文整理汇总了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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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");
}
}