org.apache.commons.cli.CommandLineParser Java Examples
The following examples show how to use
org.apache.commons.cli.CommandLineParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CliUtil.java From javatech with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
public static void prepare(String[] args) throws Exception { // commons-cli命令行参数,需要带参数值 Options options = new Options(); // sql文件路径 options.addOption("sql", true, "sql config"); // 任务名称 options.addOption("name", true, "job name"); // 解析命令行参数 CommandLineParser parser = new DefaultParser(); CommandLine cl = parser.parse(options, args); String sql = cl.getOptionValue("sql"); String name = cl.getOptionValue("name"); System.out.println("sql : " + sql); System.out.println("name : " + name); }
Example #2
Source File: ServerUtil.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public static CommandLine parseCmdLine(final String appName, String[] args, Options options, CommandLineParser parser) { HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp(appName, options, true); return null; } } catch (ParseException e) { hf.printHelp(appName, options, true); } return commandLine; }
Example #3
Source File: BaseCommandLine.java From localization_nifi with Apache License 2.0 | 6 votes |
protected CommandLine doParse(String[] args) throws CommandLineParseException { CommandLineParser parser = new DefaultParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); if (commandLine.hasOption(HELP_ARG)) { return printUsageAndThrow(null, ExitCode.HELP); } certificateAuthorityHostname = commandLine.getOptionValue(CERTIFICATE_AUTHORITY_HOSTNAME_ARG, TlsConfig.DEFAULT_HOSTNAME); days = getIntValue(commandLine, DAYS_ARG, TlsConfig.DEFAULT_DAYS); keySize = getIntValue(commandLine, KEY_SIZE_ARG, TlsConfig.DEFAULT_KEY_SIZE); keyAlgorithm = commandLine.getOptionValue(KEY_ALGORITHM_ARG, TlsConfig.DEFAULT_KEY_PAIR_ALGORITHM); keyStoreType = commandLine.getOptionValue(KEY_STORE_TYPE_ARG, getKeyStoreTypeDefault()); if (KeystoreType.PKCS12.toString().equalsIgnoreCase(keyStoreType)) { logger.info("Command line argument --" + KEY_STORE_TYPE_ARG + "=" + keyStoreType + " only applies to keystore, recommended truststore type of " + KeystoreType.JKS.toString() + " unaffected."); } signingAlgorithm = commandLine.getOptionValue(SIGNING_ALGORITHM_ARG, TlsConfig.DEFAULT_SIGNING_ALGORITHM); differentPasswordForKeyAndKeystore = commandLine.hasOption(DIFFERENT_KEY_AND_KEYSTORE_PASSWORDS_ARG); } catch (ParseException e) { return printUsageAndThrow("Error parsing command line. (" + e.getMessage() + ")", ExitCode.ERROR_PARSING_COMMAND_LINE); } return commandLine; }
Example #4
Source File: CommandLineApplication.java From validator with Apache License 2.0 | 6 votes |
/** * Hauptprogramm für die Kommandozeilen-Applikation. * * @param args die Eingabe-Argumente */ static int mainProgram(final String[] args) { int returnValue = 0; final Options options = createOptions(); if (isHelpRequested(args)) { printHelp(options); } else { try { final CommandLineParser parser = new DefaultParser(); final CommandLine cmd = parser.parse(options, args); if (cmd.hasOption(SERVER.getOpt())) { returnValue = startDaemonMode(cmd); } else if (cmd.getArgList().isEmpty()) { printHelp(createOptions()); } else { returnValue = processActions(cmd); } } catch (final ParseException e) { log.error("Error processing command line arguments: " + e.getMessage()); printHelp(options); } } return returnValue; }
Example #5
Source File: BrokerReplacement.java From doctorkafka with Apache License 2.0 | 6 votes |
/** * Usage: BrokerReplacement -broker broker1 -command "relaunch host script" */ private static CommandLine parseCommandLine(String[] args) { Option broker = new Option(BROKER, true, "broker name"); Option command = new Option(COMMAND, true, "command for relaunching a host"); options.addOption(broker).addOption(command); if (args.length < 3) { printUsageAndExit(); } CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException | NumberFormatException e) { printUsageAndExit(); } return cmd; }
Example #6
Source File: TestTFileSeek.java From hadoop with Apache License 2.0 | 6 votes |
public MyOptions(String[] args) { seed = System.nanoTime(); try { Options opts = buildOptions(); CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(opts, args, true); processOptions(line, opts); validateOptions(); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Try \"--help\" option for details."); setStopProceed(); } }
Example #7
Source File: StompClient.java From amazon-mq-workshop with Apache License 2.0 | 6 votes |
private static CommandLine parseAndValidateCommandLineArguments(String[] args) throws ParseException { Options options = new Options(); options.addOption("help", false, "Print the help message."); options.addOption("url", true, "The broker connection url."); options.addOption("user", true, "The user to connect to the broker."); options.addOption("password", true, "The password for the user."); options.addOption("mode", true, "Whether to act as 'sender' or 'receiver'"); options.addOption("type", true, "Whether to use a queue or a topic."); options.addOption("destination", true, "The name of the queue or topic"); options.addOption("name", true, "The name of the sender"); options.addOption("interval", true, "The interval in msec at which messages are generated. Default 1000"); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { printUsage(options); } if (!(cmd.hasOption("url") && cmd.hasOption("mode") && cmd.hasOption("destination"))) { printUsage(options); } return cmd; }
Example #8
Source File: HealthManager.java From Dhalion with MIT License | 6 votes |
public static void main(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); Options slaManagerCliOptions = constructCliOptions(); // parse the help options first. Options helpOptions = constructHelpOptions(); CommandLine cmd = parser.parse(helpOptions, args, true); if (cmd.hasOption("h")) { usage(slaManagerCliOptions); return; } try { cmd = parser.parse(slaManagerCliOptions, args); } catch (ParseException e) { usage(slaManagerCliOptions); throw new RuntimeException("Error parsing command line options: ", e); } LOG.info("Initializing the health manager"); HealthManager healthmgr = new HealthManager(cmd); healthmgr.start(); }
Example #9
Source File: DigestAnalyzer.java From steady with Apache License 2.0 | 6 votes |
/** * <p>main.</p> * * @param _args an array of {@link java.lang.String} objects. */ public static void main(String[] _args){ // Prepare parsing of cmd line arguments final Options options = new Options(); options.addOption("digest", "digest", true, "Delete all existing results before upload; otherwise only upload results for AffectedLibraries not already existing in the backend"); try { final CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, _args); if(cmd.hasOption("digest")){ String digest = cmd.getOptionValue("digest"); log.info("Running patcheval to assess all bugs of digest["+digest+"], all other options will be ignored."); DigestAnalyzer d = new DigestAnalyzer(digest); d.analyze(); } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example #10
Source File: CmdLineOpts.java From yb-sample-apps with Apache License 2.0 | 6 votes |
private static void parseHelpDetailed(String[] args, Options options) throws Exception { Options helpOptions = new Options(); helpOptions.addOption("help", true, "Print help."); CommandLineParser helpParser = new BasicParser(); CommandLine helpCommandLine = null; try { helpCommandLine = helpParser.parse(helpOptions, args); } catch (org.apache.commons.cli.MissingArgumentException e1) { // This is ok since there was no help argument passed. return; } catch (ParseException e) { return; } if (helpCommandLine.hasOption("help")) { printUsageDetails(options, "Usage:", helpCommandLine.getOptionValue("help")); System.exit(0); } }
Example #11
Source File: FlowPersistenceProviderMigrator.java From nifi-registry with Apache License 2.0 | 6 votes |
public static void main(String[] args) { Options options = new Options(); options.addOption("t", "to", true, "Providers xml to migrate to."); CommandLineParser parser = new DefaultParser(); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); } catch (ParseException e) { log.error("Unable to parse command line.", e); new HelpFormatter().printHelp("persistence-toolkit [args]", options); System.exit(PARSE_EXCEPTION); } NiFiRegistryProperties fromProperties = NiFiRegistry.initializeProperties(NiFiRegistry.getMasterKeyProvider()); DataSource dataSource = new DataSourceFactory(fromProperties).getDataSource(); DatabaseMetadataService fromMetadataService = new DatabaseMetadataService(new JdbcTemplate(dataSource)); FlowPersistenceProvider fromPersistenceProvider = createFlowPersistenceProvider(fromProperties, dataSource); FlowPersistenceProvider toPersistenceProvider = createFlowPersistenceProvider(createToProperties(commandLine, fromProperties), dataSource); new FlowPersistenceProviderMigrator().doMigrate(fromMetadataService, fromPersistenceProvider, toPersistenceProvider); }
Example #12
Source File: InputBindingExample.java From java-sdk with MIT License | 5 votes |
/** * The entry point of this app. * @param args The port this app will listen on. * @throws Exception The Exception. */ public static void main(String[] args) throws Exception { Options options = new Options(); options.addRequiredOption("p", "port", true, "The port this app will listen on."); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); // If port string is not valid, it will throw an exception. int port = Integer.parseInt(cmd.getOptionValue("port")); // Start Dapr's callback endpoint. DaprApplication.start(port); }
Example #13
Source File: GenericOptionsParser.java From hadoop with Apache License 2.0 | 5 votes |
/** * Parse the user-specified options, get the generic options, and modify * configuration accordingly * @param opts Options to use for parsing args. * @param conf Configuration to be modified * @param args User-specified arguments */ private void parseGeneralOptions(Options opts, Configuration conf, String[] args) throws IOException { opts = buildGeneralOptions(opts); CommandLineParser parser = new GnuParser(); try { commandLine = parser.parse(opts, preProcessForWindows(args), true); processGeneralOptions(conf, commandLine); } catch(ParseException e) { LOG.warn("options parsing failed: "+e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("general options are: ", opts); } }
Example #14
Source File: TraceIndexAnalyzer.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File rocksDBFile = new File(cl.getOptionValue(OPTION_INDEX_PATH)); if (!rocksDBFile.exists()) { System.err.format("Index file at %s does not exist, nothing to analyze", rocksDBFile.getAbsolutePath()); HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } LOGGER.info("Starting analysis"); TraceIndexAnalyzer analyzer = new TraceIndexAnalyzer(); analyzer.runExtraction( rocksDBFile, new File(cl.getOptionValue(OPTION_OUTPUT_PATH)) ); LOGGER.info("Done"); }
Example #15
Source File: CliTool.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Command parse(CliToolConfig.Cmd cmd, String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); CommandLine cli = parser.parse(CliToolConfig.OptionsSource.HELP.options(), args, true); if (cli.hasOption("h")) { return helpCmd(cmd); } cli = parser.parse(cmd.options(), args, cmd.isStopAtNonOption()); Terminal.Verbosity verbosity = Terminal.Verbosity.resolve(cli); terminal.verbosity(verbosity); return parse(cmd.name(), cli); }
Example #16
Source File: CommandLineArguments.java From zserio with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Parses the command line arguments. * * @param args Command line arguments to parse. * * @throws ParseException Throws if any parse error occurred. */ public void parse(String[] args) throws ParseException { CommandLineParser cliParser = new DefaultParser(); parsedCommandLine = cliParser.parse(options, args, false); readArguments(); readOptions(); }
Example #17
Source File: Predict.java From ltr4l with Apache License 2.0 | 5 votes |
public static CommandLine getCommandLine(Options options, String[] args){ CommandLineParser parser = new DefaultParser(); CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); } catch(ParseException exp) { // oops, something went wrong System.err.printf("Parsing failed. Reason: %s\n\n", exp.getMessage()); printUsage(options); } return line; }
Example #18
Source File: KafkaStatsMain.java From doctorkafka with Apache License 2.0 | 5 votes |
/** * Usage: com.pinterest.kafka.KafkaStatsMain --host kafkahost --port 9999 * --zookeeper datazk001:2181/data05 --topic kafka_metrics * --stats_producer_config producer_config.properties --tsdhost localhost:18321 * --ostrichport 2051 --uptimeinseconds 43200 --pollinginterval 15 * --kafka_config /etc/kafka/server.properties */ private static CommandLine parseCommandLine(String[] args) { Option host = new Option(BROKER_NAME, true, "kafka broker"); host.setRequired(false); Option jmxPort = new Option(JMX_PORT, true, "kafka jmx port number"); jmxPort.setArgName("kafka jmx port number"); Option zookeeper = new Option(ZOOKEEPER, true, "zk url for metrics topic"); Option topic = new Option(METRICS_TOPIC, true, "kafka topic for metric messages"); Option tsdHostPort = new Option(TSD_HOSTPORT, true, "tsd host and port, e.g. localhost:18621"); Option ostrichPort = new Option(OSTRICH_PORT, true, "ostrich port"); Option uptimeInSeconds = new Option(UPTIME_IN_SECONDS, true, "uptime in seconds"); Option pollingInterval = new Option(POLLING_INTERVAL, true, "polling interval in seconds"); Option kafkaConfig = new Option(KAFKA_CONFIG, true, "kafka server properties file path"); Option disableEc2metadata = new Option(DISABLE_EC2METADATA, false, "Disable collecting host information via ec2metadata"); Option statsProducerConfig = new Option(STATS_PRODUCER_CONFIG, true, "kafka_stats producer config"); Option primaryNetworkInterfaceName = new Option(PRIMARY_INTERFACE_NAME, true, "network interface used by kafka"); options.addOption(jmxPort).addOption(host).addOption(zookeeper).addOption(topic) .addOption(tsdHostPort).addOption(ostrichPort).addOption(uptimeInSeconds) .addOption(pollingInterval).addOption(kafkaConfig).addOption(statsProducerConfig) .addOption(primaryNetworkInterfaceName).addOption(disableEc2metadata); if (args.length < 6) { printUsageAndExit(); } CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException | NumberFormatException e) { printUsageAndExit(); } return cmd; }
Example #19
Source File: AutogenSettings.java From deploymentmanager-autogen with Apache License 2.0 | 5 votes |
static AutogenSettings build(String[] args) throws ParseException { Options options = buildCommandOptions(); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption(OPTION_HELP)) { printUsage(options); System.exit(0); } validateCliOptions(cmd); AutogenSettings settings = new AutogenSettings(); if (cmd.hasOption(OPTION_SINGLE_INPUT)) { settings.input = cmd.getOptionValue(OPTION_SINGLE_INPUT, settings.input); settings.singleMode = true; } if (cmd.hasOption(OPTION_BATCH_INPUT)) { settings.input = cmd.getOptionValue(OPTION_BATCH_INPUT, settings.input); settings.singleMode = false; } settings.output = cmd.getOptionValue(OPTION_OUTPUT, settings.output); settings.inputType = InputType.valueOf(cmd.getOptionValue(OPTION_INPUT_TYPE, settings.inputType.name())); settings.outputType = OutputType.valueOf(cmd.getOptionValue(OPTION_OUTPUT_TYPE, settings.outputType.name())); settings.excludeSharedSupportFiles = cmd.hasOption(OPTION_EXCLUDE_SHARED_SUPPORT_FILES); return settings; }
Example #20
Source File: DeletePathFinderTest.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Test public void testFindWildcard() throws Exception { final CommandLineParser parser = new PosixParser(); final CommandLine input = parser.parse(TerminalOptionsBuilder.options(), new String[]{"--delete", "rackspace://cdn.cyberduck.ch/remote/*.txt"}); assertTrue(new DeletePathFinder().find(input, TerminalAction.delete, new Path("/remote/*.txt", EnumSet.of(Path.Type.file))).contains( new TransferItem(new Path("/remote", EnumSet.of(Path.Type.directory))) )); }
Example #21
Source File: WordCountProcessor.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { System.out.println("Starting up..."); System.out.flush(); Options opts = new Options(); opts.addOption(Option.builder("i"). longOpt("input").hasArg().required().desc("Input file or directory to score").build()); opts.addOption(Option.builder("h").longOpt("help").desc("Print this help message and exit").build()); opts.addOption(Option.builder("v").longOpt("verbose").desc("Print verbose log output").build()); HelpFormatter helpFormatter = new HelpFormatter(); CommandLineParser cmdLineParser = new DefaultParser(); CommandLine cmdLine = null; try { cmdLine = cmdLineParser.parse(opts, args); } catch (ParseException e) { System.out.println("Caught exception when parsing command line: " + e.getMessage()); helpFormatter.printHelp("WordCountProcessor", opts); System.exit(1); } if (cmdLine.hasOption("help")) { helpFormatter.printHelp("DocumentIndexer", opts); System.exit(0); } String inputFileOrDir = cmdLine.getOptionValue("input"); File splitFileOrDir = new File(inputFileOrDir); if (!(splitFileOrDir.exists())) { LOGGER.error("Unable to find directory at " + inputFileOrDir); System.exit(1); } WordCountProcessor wcp = new WordCountProcessor(); PatentCorpusReader corpusReader = new PatentCorpusReader(wcp, splitFileOrDir); corpusReader.readPatentCorpus(); }
Example #22
Source File: ReactionRenderer.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws IOException { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(ReactionRenderer.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(ReactionRenderer.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } Integer height = Integer.parseInt(cl.getOptionValue(OPTION_HEIGHT, "1000")); Integer width = Integer.parseInt(cl.getOptionValue(OPTION_WIDTH, "1000")); Boolean representCofactors = cl.hasOption(OPTION_COFACTOR) && Boolean.parseBoolean(cl.getOptionValue(OPTION_COFACTOR)); NoSQLAPI api = new NoSQLAPI(cl.getOptionValue(OPTION_READ_DB), cl.getOptionValue(OPTION_READ_DB)); for (String val : cl.getOptionValues(OPTION_RXN_IDS)) { Long reactionId = Long.parseLong(val); ReactionRenderer renderer = new ReactionRenderer(cl.getOptionValue(OPTION_FILE_FORMAT), width, height); renderer.drawReaction(api.getReadDB(), reactionId, cl.getOptionValue(OPTION_DIR_PATH), representCofactors); LOGGER.info(renderer.getSmartsForReaction(api.getReadDB(), reactionId, representCofactors)); } }
Example #23
Source File: Subscriber.java From java-sdk with MIT License | 5 votes |
/** * This is the entry point for this example app, which subscribes to a topic. * @param args The port this app will listen on. * @throws Exception An Exception on startup. */ public static void main(String[] args) throws Exception { Options options = new Options(); options.addRequiredOption("p", "port", true, "The port this app will listen on"); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); // If port string is not valid, it will throw an exception. int port = Integer.parseInt(cmd.getOptionValue("port")); // Start Dapr's callback endpoint. DaprApplication.start(port); }
Example #24
Source File: DemoService.java From java-sdk with MIT License | 5 votes |
/** * Starts the service. * @param args Expects the port: -p PORT * @throws Exception If cannot start service. */ public static void main(String[] args) throws Exception { Options options = new Options(); options.addRequiredOption("p", "port", true, "Port to listen to."); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); // If port string is not valid, it will throw an exception. int port = Integer.parseInt(cmd.getOptionValue("port")); DaprApplication.start(port); }
Example #25
Source File: CommandArgs.java From SikuliX1 with MIT License | 5 votes |
public CommandLine getCommandLine(String[] args) { CommandLineParser parser = new PosixParser(); CommandLine cmd = null; boolean isUserArg = false; for (int i = 0; i < args.length; i++) { if (!isUserArg && args[i].startsWith("--")) { isUserArg = true; continue; } if (isUserArg) { userArgs.add(args[i]); } else { sikuliArgs.add(args[i]); } } try { cmd = parser.parse(cmdArgs, sikuliArgs.toArray(new String[]{}), true); } catch (ParseException exp) { Debug.error(exp.getMessage()); } return cmd; }
Example #26
Source File: EcdsaKeyPairGenerator.java From capillary with Apache License 2.0 | 5 votes |
private static CommandLine generateCommandLine(String[] commandLineArguments) throws ParseException { Option ecdsaPublicKeyPath = Option.builder() .longOpt(ECDSA_PUBLIC_KEY_PATH_OPTION) .desc("The path to store ECDSA public key.") .hasArg() .required() .build(); Option ecdsaPrivateKeyPath = Option.builder() .longOpt(ECDSA_PRIVATE_KEY_PATH_OPTION) .desc("The path to store ECDSA private key.") .hasArg() .required() .build(); Options options = new Options(); options.addOption(ecdsaPublicKeyPath); options.addOption(ecdsaPrivateKeyPath); CommandLineParser cmdLineParser = new DefaultParser(); return cmdLineParser.parse(options, commandLineArguments); }
Example #27
Source File: CladeTraversal.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(CladeTraversal.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(CladeTraversal.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } String targetInchi = cl.getOptionValue(OPTION_TARGET_INCHI, PABA_INCHI); String inchiFileName = cl.getOptionValue(OPTION_OUTPUT_INCHI_FILE_NAME, DEFAULT_INCHI_FILE); String reactionsFileName = cl.getOptionValue(OPTION_OUTPUT_REACTION_FILE_NAME, DEFAULT_REACTIONS_FILE); String reactionDirectory = cl.getOptionValue(OPTION_OUTPUT_FAILED_REACTIONS_DIR_NAME, "/"); String actDataFile = cl.getOptionValue(OPTION_ACT_DATA_FILE, DEFAULT_ACTDATA_FILE); runCladeExpansion(actDataFile, targetInchi, inchiFileName, reactionsFileName, reactionDirectory); }
Example #28
Source File: IoTDBDescriptor.java From incubator-iotdb with Apache License 2.0 | 5 votes |
private boolean parseCommandLine(Options options, String[] params) { try { CommandLineParser parser = new DefaultParser(); commandLine = parser.parse(options, params); } catch (ParseException e) { logger.error("parse conf params failed, {}", e.toString()); return false; } return true; }
Example #29
Source File: Client.java From dubbo-benchmark with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.out.println(args); org.apache.commons.cli.Options options = new org.apache.commons.cli.Options(); options.addOption(Option.builder().longOpt("warmupIterations").hasArg().build()); options.addOption(Option.builder().longOpt("warmupTime").hasArg().build()); options.addOption(Option.builder().longOpt("measurementIterations").hasArg().build()); options.addOption(Option.builder().longOpt("measurementTime").hasArg().build()); CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); int warmupIterations = Integer.valueOf(line.getOptionValue("warmupIterations", "3")); int warmupTime = Integer.valueOf(line.getOptionValue("warmupTime", "10")); int measurementIterations = Integer.valueOf(line.getOptionValue("measurementIterations", "3")); int measurementTime = Integer.valueOf(line.getOptionValue("measurementTime", "10")); Options opt; ChainedOptionsBuilder optBuilder = new OptionsBuilder() .include(Client.class.getSimpleName()) .warmupIterations(warmupIterations) .warmupTime(TimeValue.seconds(warmupTime)) .measurementIterations(measurementIterations) .measurementTime(TimeValue.seconds(measurementTime)) .threads(CONCURRENCY) .forks(1); opt = doOptions(optBuilder).build(); new Runner(opt).run(); }
Example #30
Source File: CLIUtil.java From act with GNU General Public License v3.0 | 5 votes |
public CommandLine parseCommandLine(String[] args) { CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { LOGGER.error("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(callingClass.getCanonicalName(), helpMessage, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(callingClass.getCanonicalName(), helpMessage, opts, null, true); System.exit(0); } commandLine = cl; return cl; }