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

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

本文整理了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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  CommandLine cl;
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  return this;
}

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

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

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

private void retainCompatibility(String[] cmdArgs) throws CliParseException {
  // stat path [watch]
  if (args.length > 2) {
    // rewrite to option
    cmdArgs[2] = "-w";
    err.println("'stat path [watch]' has been deprecated. "
        + "Please use 'stat [-w] path' instead.");
    Parser parser = new PosixParser();
    try {
      cl = parser.parse(options, cmdArgs);
    } catch (ParseException ex) {
      throw new CliParseException(ex);
    }
    args = cl.getArgs();
  }
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (cl.hasOption("?")) {
    printHelp();
  }
  retainCompatibility(cmdArgs);
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 3) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 1) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 3) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if(args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  CommandLine cl;
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  CommandLine cl;
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  CommandLine cl;
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  CommandLine cl;
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  CommandLine cl;
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if(args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  
  retainCompatibility(cmdArgs);
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if(args.length < 2) {
    throw new CliParseException(getUsageStr());
  }    
  
  retainCompatibility(cmdArgs);
  return this;
}

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

@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
  Parser parser = new PosixParser();
  try {
    cl = parser.parse(options, cmdArgs);
  } catch (ParseException ex) {
    throw new CliParseException(ex);
  }
  args = cl.getArgs();
  if (args.length < 2) {
    throw new CliParseException(getUsageStr());
  }
  retainCompatibility(cmdArgs);
  return this;
}

相关文章