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


Java Options類代碼示例

本文整理匯總了Java中org.apache.commons.cli.Options的典型用法代碼示例。如果您正苦於以下問題:Java Options類的具體用法?Java Options怎麽用?Java Options使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: buildCommandlineOptions

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "groupName", true, "consumer group name");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:9,代碼來源:ConsumerProgressSubCommand.java

示例2: main

import org.apache.commons.cli.Options; //導入依賴的package包/類
/**
 * Main method.
 * 
 * @param args
 * @throws IOException
 * @throws ParseException
 */
public static void main(String[] args) throws Exception {
	java.util.logging.Logger l = java.util.logging.Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
	l.setLevel(java.util.logging.Level.FINE);
	l.setUseParentHandlers(false);
	java.util.logging.ConsoleHandler ch = new java.util.logging.ConsoleHandler();
	ch.setLevel(java.util.logging.Level.ALL);
	l.addHandler(ch);

	CommandLineParser parser = new GnuParser();
	Options options = new Options();
	options.addOption("h", "host", true, "Server hostname.");
	options.addOption("p", "port", true, "TCP port to listen.");
	options.addOption("s", "storage_path", true, "Storage path.");
	options.addOption("w", "wat_gcube_token", true, "WAT gcube authentication token");
	CommandLine line = parser.parse(options, args);

	String serverUri = String.format("http://%s:%d/smaph", line.getOptionValue("host", "localhost"),
	        Integer.parseInt(line.getOptionValue("port", "8080")));
	Path storage = Paths.get(line.getOptionValue("storage_path"));
	startServer(serverUri, storage, line.getOptionValue("wat_gcube_token"));
}
 
開發者ID:marcocor,項目名稱:smaph,代碼行數:29,代碼來源:ServerMain.java

示例3: testCreateWithOptions

import org.apache.commons.cli.Options; //導入依賴的package包/類
/**
 * Test that options passed to the constructor are used.
 */
@SuppressWarnings("static-access")
public void testCreateWithOptions() throws Exception {
  // Create new option newOpt
  Option opt = OptionBuilder.withArgName("int")
  .hasArg()
  .withDescription("A new option")
  .create("newOpt");
  Options opts = new Options();
  opts.addOption(opt);

  // Check newOpt is actually used to parse the args
  String[] args = new String[2];
  args[0] = "--newOpt";
  args[1] = "7";
  GenericOptionsParser g = new GenericOptionsParser(opts, args);
  assertEquals("New option was ignored",
    "7", g.getCommandLine().getOptionValues("newOpt")[0]);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:22,代碼來源:TestGenericOptionsParser.java

示例4: main

import org.apache.commons.cli.Options; //導入依賴的package包/類
public static void main(String[] args) {
    CommandLineParser parser = new DefaultParser();
    try {
        Options options = getOptions();
        CommandLine line = parser.parse(options, args );
        if (line.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            System.out.println(Constants.PROJECT_NAME + ", " + Constants.PROJECT_URL);
            formatter.printHelp(Constants.PROJECT_NAME, options, true);
        } else if (line.hasOption("version")) {
            System.out.println("version: " + Constants.VERSION);
        } else {
            logger.info("Starting pm-home-station ({} v.{})...", Constants.PROJECT_URL, Constants.VERSION);
            setLookAndFeel();
            PlanTowerSensor planTowerSensor = new PlanTowerSensor();
            Station station = new Station(planTowerSensor);
            SwingUtilities.invokeLater(() -> { station.showUI(); });
        }
    } catch (ParseException e) {
        logger.error("Ooops", e);
        return;
    }
}
 
開發者ID:rjaros87,項目名稱:pm-home-station,代碼行數:24,代碼來源:Start.java

示例5: getOptions

import org.apache.commons.cli.Options; //導入依賴的package包/類
private static Options getOptions() {
    Options options = new Options();
    options.addOption(
            Option.builder("in").longOpt(PARAMETER_INPUT_FILE).argName("input file").hasArg().desc("Input file. Can be a .rpx or .rpx").required().build());
    options.addOption(Option.builder("f").longOpt(PARAMETER_FUNCTION_NAME).argName("The function name to be searched in the input file").hasArg().desc("").build());
    options.addOption(Option.builder("m").longOpt(PARAMETER_MAX_SIGNATURE_LENGTH).hasArg()
            .desc("Maximum length of the signature that will be checked. Default is " + SIGNATURE_LENGTH).optionalArg(true).build());
    options.addOption(Option.builder("t").longOpt(PARAMETER_FILTER_FILE).hasArg().argName("file").desc("A file containing a list of Hex Strings representing a list of TitleIDs in the folder " + RPX_WITH_SYMBOLS_FOLDER + " that should be used.").build());
    options.addOption(Option.builder("v").longOpt(PARAMETER_VERBOSE_LOGGING).desc("Enables verbose logging").build());
    options.addOption(Option.builder("e").longOpt(PARAMETER_EXTRA_FUNCTIONS).argName("filename").hasArg().desc("A file contains a list of functions that should be checked.").build());
    options.addOption(Option.builder("s").longOpt(PARAMETER_RPX_WITH_SYMBOLS_FOLDER).hasArg().argName("filename").desc("Sets the path to the folder which contains folders (named the TITLEID) which contain the RPX files with symbols.=> A folder containing this: /1234567812345678/test.rpx /1234567812345698/test2.rpx").build());

    options.addOption("help", false, "Shows this text");

    return options;
}
 
開發者ID:Maschell,項目名稱:nn_nex_logging_and_research,代碼行數:17,代碼來源:StarterFunctionFinder.java

示例6: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);
        String json = topicRouteData.toJson(true);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:20,代碼來源:TopicRouteSubCommand.java

示例7: getOptions

import org.apache.commons.cli.Options; //導入依賴的package包/類
/**
 * Creates an Options object, returns it.
 * @return Returns all acceptable command-line options.
 */
private static Options getOptions() {
    Options opts = new Options();
    opts.addOption("h", "help", false, "Print the help");
    opts.addOption("u", "url", true, "URL of album to rip");
    opts.addOption("t", "threads", true, "Number of download threads per rip");
    opts.addOption("w", "overwrite", false, "Overwrite existing files");
    opts.addOption("r", "rerip", false, "Re-rip all ripped albums");
    opts.addOption("R", "rerip-selected", false, "Re-rip all selected albums");
    opts.addOption("d", "saveorder", false, "Save the order of images in album");
    opts.addOption("D", "nosaveorder", false, "Don't save order of images");
    opts.addOption("4", "skip404", false, "Don't retry after a 404 (not found) error");
    opts.addOption("l", "ripsdirectory", true, "Rips Directory (Default: ./rips)");
    opts.addOption("n", "no-prop-file", false, "Do not create properties file.");
    opts.addOption("f", "urls-file", true, "Rip URLs from a file.");
    opts.addOption("v", "version", false, "Show current version");
    return opts;
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:22,代碼來源:App.java

示例8: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    String topic = commandLine.getOptionValue('t').trim();
    try {
        defaultMQAdminExt.start();
        Set<String> clusters = defaultMQAdminExt.getTopicClusterList(topic);
        for (String value : clusters) {
            System.out.printf("%s%n", value);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:18,代碼來源:TopicClusterSubCommand.java

示例9: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        final String topic = commandLine.getOptionValue('t').trim();
        final String key = commandLine.getOptionValue('k').trim();

        this.queryByKey(defaultMQAdminExt, topic, key);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:18,代碼來源:QueryMsgByKeySubCommand.java

示例10: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        String topic = commandLine.getOptionValue('t').trim();

        if (commandLine.hasOption('c')) {
            String clusterName = commandLine.getOptionValue('c').trim();

            adminExt.start();
            deleteTopic(adminExt, clusterName, topic);
            return;
        }

        ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:23,代碼來源:DeleteTopicSubCommand.java

示例11: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    String topic = commandLine.getOptionValue('t').trim();
    try {
        defaultMQAdminExt.start();
        Set<String> clusters = defaultMQAdminExt.getTopicClusterList(topic);
        for (String value : clusters){
            System.out.println(value);
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
開發者ID:y123456yz,項目名稱:reading-and-annotate-rocketmq-3.4.6,代碼行數:20,代碼來源:TopicClusterSubCommand.java

示例12: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // namespace
        String namespace = commandLine.getOptionValue('s').trim();
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();

        defaultMQAdminExt.start();
        defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value);
        System.out.printf("create or update kv config to namespace success.\n");
        return;
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
開發者ID:y123456yz,項目名稱:reading-and-annotate-rocketmq-3.4.6,代碼行數:25,代碼來源:UpdateKvConfigCommand.java

示例13: MyOptions

import org.apache.commons.cli.Options; //導入依賴的package包/類
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();
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:17,代碼來源:TestTFileSeqFileComparison.java

示例14: getOptions

import org.apache.commons.cli.Options; //導入依賴的package包/類
private static Options getOptions() {
    Options options = new Options();
    //options.addOption("noui", false, "no UI, console only");
    options.addOption("h", "help", false, "print this message and exit");
    options.addOption("v", "version", false, "print the version information and exit");
    return options;
}
 
開發者ID:rjaros87,項目名稱:pm-home-station,代碼行數:8,代碼來源:Start.java

示例15: execute

import org.apache.commons.cli.Options; //導入依賴的package包/類
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        boolean result = false;
        defaultMQAdminExt.start();
        if (commandLine.hasOption('b')) {
            String addr = commandLine.getOptionValue('b').trim();
            result = defaultMQAdminExt.cleanUnusedTopicByAddr(addr);

        } else {
            String cluster = commandLine.getOptionValue('c');
            if (null != cluster)
                cluster = cluster.trim();
            result = defaultMQAdminExt.cleanUnusedTopicByAddr(cluster);
        }
        System.out.printf(result ? "success" : "false");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:26,代碼來源:CleanUnusedTopicCommand.java


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