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