org.apache.commons.cli.Parser.parse()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(251)

本文整理了Java中org.apache.commons.cli.Parser.parse()方法的一些代码示例,展示了Parser.parse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.parse()方法的具体详情如下:
包路径:org.apache.commons.cli.Parser
类名称:Parser
方法名:parse

Parser.parse介绍

[英]Parses the specified arguments based on the specifed Options.
[中]

代码示例

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. CommandLine cl;
  5. try {
  6. cl = parser.parse(options, cmdArgs);
  7. } catch (ParseException ex) {
  8. throw new CliParseException(ex);
  9. }
  10. args = cl.getArgs();
  11. return this;
  12. }

代码示例来源:origin: apache/zookeeper

  1. private void retainCompatibility(String[] cmdArgs) throws CliParseException {
  2. if (args.length > 2) {
  3. err.println("'delete path [version]' has been deprecated. "
  4. + "Please use 'delete [-v version] path' instead.");
  5. Parser parser = new PosixParser();
  6. try {
  7. cl = parser.parse(options, cmdArgs);
  8. } catch (ParseException ex) {
  9. throw new CliParseException(ex);
  10. }
  11. args = cl.getArgs();
  12. }
  13. }

代码示例来源:origin: apache/zookeeper

  1. private void retainCompatibility(String[] cmdArgs) throws CliParseException {
  2. // stat path [watch]
  3. if (args.length > 2) {
  4. // rewrite to option
  5. cmdArgs[2] = "-w";
  6. err.println("'stat path [watch]' has been deprecated. "
  7. + "Please use 'stat [-w] path' instead.");
  8. Parser parser = new PosixParser();
  9. try {
  10. cl = parser.parse(options, cmdArgs);
  11. } catch (ParseException ex) {
  12. throw new CliParseException(ex);
  13. }
  14. args = cl.getArgs();
  15. }
  16. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (cl.hasOption("?")) {
  11. printHelp();
  12. }
  13. retainCompatibility(cmdArgs);
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 3) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 1) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 3) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if(args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. return this;
  14. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. CommandLine cl;
  5. try {
  6. cl = parser.parse(options, cmdArgs);
  7. } catch (ParseException ex) {
  8. throw new CliParseException(ex);
  9. }
  10. args = cl.getArgs();
  11. if (args.length < 2) {
  12. throw new CliParseException(getUsageStr());
  13. }
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. CommandLine cl;
  5. try {
  6. cl = parser.parse(options, cmdArgs);
  7. } catch (ParseException ex) {
  8. throw new CliParseException(ex);
  9. }
  10. args = cl.getArgs();
  11. if (args.length < 2) {
  12. throw new CliParseException(getUsageStr());
  13. }
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. CommandLine cl;
  5. try {
  6. cl = parser.parse(options, cmdArgs);
  7. } catch (ParseException ex) {
  8. throw new CliParseException(ex);
  9. }
  10. args = cl.getArgs();
  11. if (args.length < 2) {
  12. throw new CliParseException(getUsageStr());
  13. }
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. CommandLine cl;
  5. try {
  6. cl = parser.parse(options, cmdArgs);
  7. } catch (ParseException ex) {
  8. throw new CliParseException(ex);
  9. }
  10. args = cl.getArgs();
  11. if (args.length < 2) {
  12. throw new CliParseException(getUsageStr());
  13. }
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. CommandLine cl;
  5. try {
  6. cl = parser.parse(options, cmdArgs);
  7. } catch (ParseException ex) {
  8. throw new CliParseException(ex);
  9. }
  10. args = cl.getArgs();
  11. if(args.length < 2) {
  12. throw new CliParseException(getUsageStr());
  13. }
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. retainCompatibility(cmdArgs);
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if(args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. retainCompatibility(cmdArgs);
  14. return this;
  15. }

代码示例来源:origin: apache/zookeeper

  1. @Override
  2. public CliCommand parse(String[] cmdArgs) throws CliParseException {
  3. Parser parser = new PosixParser();
  4. try {
  5. cl = parser.parse(options, cmdArgs);
  6. } catch (ParseException ex) {
  7. throw new CliParseException(ex);
  8. }
  9. args = cl.getArgs();
  10. if (args.length < 2) {
  11. throw new CliParseException(getUsageStr());
  12. }
  13. retainCompatibility(cmdArgs);
  14. return this;
  15. }

相关文章