當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。