当前位置: 首页>>代码示例>>Java>>正文


Java CommandLine.hasOption方法代码示例

本文整理汇总了Java中org.apache.commons.cli.CommandLine.hasOption方法的典型用法代码示例。如果您正苦于以下问题:Java CommandLine.hasOption方法的具体用法?Java CommandLine.hasOption怎么用?Java CommandLine.hasOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.cli.CommandLine的用法示例。


在下文中一共展示了CommandLine.hasOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transitionToActive

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private int transitionToActive(final CommandLine cmd)
    throws IOException, ServiceFailedException {
  String[] argv = cmd.getArgs();
  if (argv.length != 1) {
    errOut.println("transitionToActive: incorrect number of arguments");
    printUsage(errOut, "-transitionToActive");
    return -1;
  }
  /*  returns true if other target node is active or some exception occurred 
      and forceActive was not set  */
  if(!cmd.hasOption(FORCEACTIVE)) {
    if(isOtherTargetNodeActive(argv[0], cmd.hasOption(FORCEACTIVE))) {
      return -1;
    }
  }
  HAServiceTarget target = resolveTarget(argv[0]);
  if (!checkManualStateManagementOK(target)) {
    return -1;
  }
  HAServiceProtocol proto = target.getProxy(
      getConf(), 0);
  HAServiceProtocolHelper.transitionToActive(proto, createReqInfo());
  return 0;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:HAAdmin.java

示例2: execute

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    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) {
        e.printStackTrace();
    }
    finally {
        adminExt.shutdown();
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:25,代码来源:DeleteTopicSubCommand.java

示例3: execute

import org.apache.commons.cli.CommandLine; //导入方法依赖的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.cleanExpiredConsumerQueueByAddr(addr);

        } else {
            String cluster = commandLine.getOptionValue('c');
            if (null != cluster)
                cluster = cluster.trim();
            result = defaultMQAdminExt.cleanExpiredConsumerQueue(cluster);
        }
        System.out.printf(result ? "success" : "false");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:26,代码来源:CleanExpiredCQSubCommand.java

示例4: getProbandListStatusLogLevelOptionValue

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private static ProbandListStatusLogLevel getProbandListStatusLogLevelOptionValue(CommandLine line, boolean required) throws Exception {
	if (required && !line.hasOption(DBToolOptions.PROBAND_LIST_STATUS_LOG_LEVEL_OPT)) {
		throw new IllegalArgumentException("proband list status log level required");
	}
	String option = line.getOptionValue(DBToolOptions.PROBAND_LIST_STATUS_LOG_LEVEL_OPT);
	if (!CommonUtil.isEmptyString(option)) {
		try {
			return ProbandListStatusLogLevel.fromString(option);
		} catch (IllegalArgumentException e) {
			throw new IllegalArgumentException("proband list status log level: level name required, one of " + StringUtils.join(ProbandListStatusLogLevel.names(), ", "));
		}
	} else if (required) {
		throw new IllegalArgumentException("empty proband list status log level");
	} else {
		return null;
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:18,代码来源:DBTool.java

示例5: execute

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    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) {
        e.printStackTrace();
    } finally {
        adminExt.shutdown();
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:23,代码来源:DeleteTopicSubCommand.java

示例6: getEmailRecipients

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private static StringBuilder getEmailRecipients(CommandLine line, boolean send) {
	StringBuilder recipients = new StringBuilder();
	if (line.hasOption(DBToolOptions.EMAIL_RECIPIENTS_OPT)) {
		if (recipients.length() > 0) {
			recipients.append(DEFAULT_EMAIL_ADDRESS_SEPARATOR);
		}
		recipients.append(line.getOptionValue(DBToolOptions.EMAIL_RECIPIENTS_OPT));
	}
	if (line.hasOption(DBToolOptions.EMAIL_RECIPIENTS_IF_COUNT_GT_ZERO_OPT) && send) {
		if (recipients.length() > 0) {
			recipients.append(DEFAULT_EMAIL_ADDRESS_SEPARATOR);
		}
		recipients.append(line.getOptionValue(DBToolOptions.EMAIL_RECIPIENTS_IF_COUNT_GT_ZERO_OPT));
	}
	return recipients;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:17,代码来源:JobOutput.java

示例7: applyOptions

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
@Override
/** {@inheritDoc} */
public void applyOptions(CommandLine in, SqoopOptions out)
    throws InvalidOptionsException {

  if (in.hasOption(TABLE_ARG)) {
    out.setTableName(in.getOptionValue(TABLE_ARG));
  }

  out.setHiveImport(true);

  applyCommonOptions(in, out);
  applyHiveOptions(in, out);
  applyOutputFormatOptions(in, out);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:16,代码来源:CreateHiveTableTool.java

示例8: sanityCheckOptions

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private boolean sanityCheckOptions(CommandLine cmd) {
  boolean success = true;
  for (String reqOpt : requiredOptions) {
    if (!cmd.hasOption(reqOpt)) {
      LOG.error("Required option -" + reqOpt + " is missing");
      success = false;
    }
  }
  return success;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:AbstractHBaseTool.java

示例9: optionToConf

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private static void optionToConf(CommandLine cmd, String option,
    Configuration conf, String destConfKey) {
  if (cmd.hasOption(option)) {
    String value = cmd.getOptionValue(option);
    LOG.info("Set configuration key:" + destConfKey + " value:" + value);
    conf.set(destConfKey, value);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:ThriftServer.java

示例10: main

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
public static void main(String[] args) {
    CommandLineParser parser = new DefaultParser();
    CommandLine cli = null;
    try {

        cli = parser.parse(OptionsArgsName.getAllSupportOption(), args);

        if (cli.hasOption(OptionsArgsName.HELP)) {
            OptionsArgsName.printHelpOption();
            return;
        }
    } catch (ParseException exp) {
        System.err.println("Parsing Argument failed. Reason: " + exp.getMessage());
        OptionsArgsName.printHelpOption();
        return;
    }

    ConfigReader configReader = new ConfigReader(cli);
    if (!configReader.isInitConfigFlag()) {
        System.err.println(configReader.getInitErrMsg());
        return;
    }
    Statistics.instance.start();
    HdfsToCos hdfsToCos = new HdfsToCos(configReader);
    hdfsToCos.run();
    Statistics.instance.printStatics();
}
 
开发者ID:tencentyun,项目名称:hdfs_to_cos_tools,代码行数:28,代码来源:App.java

示例11: getAuthenticationOptionValue

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private static AuthenticationVO getAuthenticationOptionValue(CommandLine line) throws Exception {
	if (!line.hasOption(DBToolOptions.USERNAME_OPT)) {
		throw new IllegalArgumentException("username required");
	}
	if (!line.hasOption(DBToolOptions.PASSWORD_OPT)) {
		throw new IllegalArgumentException("password required");
	}
	return new AuthenticationVO(line.getOptionValue(DBToolOptions.USERNAME_OPT), line.getOptionValue(DBToolOptions.PASSWORD_OPT), null, "localhost");
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:DBTool.java

示例12: doMain

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
void doMain(String[] args) {
	Options o = new Options();

	Option help = new Option("h", "help", false,
			"display this help message");
	o.addOption(help);

	Option primes = new Option("p", "primes", true,
			"print <count> first prime numbers");
	primes.setArgName("count");
	o.addOption(primes);

	Option generatedBean = new Option("g", "generatedbean", true,
			"use generated javabean by setting s=<sValue>");
	generatedBean.setArgName("sValue");
	o.addOption(generatedBean);

	Option unsignedByte = new Option("u", "unsigned-byte", true,
			"use joulu-unsigned-byte to convert <int> to"
					+ " unsigned byte and display information");
	unsignedByte.setArgName("int");
	o.addOption(unsignedByte);

	CommandLineParser parser = new DefaultParser();

	CommandLine cmd;
	try {
		cmd = parser.parse(o, args);
	} catch (ParseException e) {
		showHelpAndExit(o);
		return;
	}
	if (cmd.hasOption(help.getOpt())) {
		showHelpAndExit(o);
		return;
	}
	if (cmd.hasOption(primes.getOpt())) {
		int count = Integer.parseInt(cmd.getOptionValue(primes.getOpt()));
		printPrimes(count);
		return;
	}
	if (cmd.hasOption(generatedBean.getOpt())) {
		String v = cmd.getOptionValue(generatedBean.getOpt());
		useGeneratedBean(v);
		return;
	}
	if (cmd.hasOption(unsignedByte.getOpt())) {
		int value = Integer
				.parseInt(cmd.getOptionValue(unsignedByte.getOpt()));
		useJouluUnsignedByte(value);
		return;
	}
	showHelpAndExit(o);
	return;
}
 
开发者ID:wipu,项目名称:iwant-demo,代码行数:56,代码来源:IwantDemoCli.java

示例13: parse

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
@Override
protected void parse(CommandLine commandLine) {
  super.parse(commandLine);
  this.server = commandLine.getOptionValue("s", server);
  this.quiet = commandLine.hasOption("q");
}
 
开发者ID:rockscript,项目名称:rockscript,代码行数:7,代码来源:ClientCommand.java

示例14: getDepartmentPassword

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private static String getDepartmentPassword(CommandLine line) throws Exception {
	if (!line.hasOption(DBToolOptions.DEPARTMENT_PASSWORD_OPT)) {
		throw new IllegalArgumentException("department password required");
	}
	return line.getOptionValue(DBToolOptions.DEPARTMENT_PASSWORD_OPT);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:7,代码来源:DBTool.java

示例15: getLongOrNull

import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private Long getLongOrNull(CommandLine cmd, String option) {
  if (!cmd.hasOption(option)) return null;
  return Long.parseLong(cmd.getOptionValue(option));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:5,代码来源:StripeCompactionsPerformanceEvaluation.java


注:本文中的org.apache.commons.cli.CommandLine.hasOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。