本文整理匯總了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");
}
}