Java Code Examples for org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine#getArgList()

The following examples show how to use org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine#getArgList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBCK2.java    From hbase-operator-tools with Apache License 2.0 5 votes vote down vote up
List<Long> assigns(Hbck hbck, String[] args) throws IOException {
  Options options = new Options();
  Option override = Option.builder("o").longOpt("override").build();
  Option inputFile = Option.builder("i").longOpt("inputFiles").build();
  options.addOption(override);
  options.addOption(inputFile);
  // Parse command-line.
  CommandLineParser parser = new DefaultParser();
  CommandLine commandLine;
  try {
    commandLine = parser.parse(options, args, false);
  } catch (ParseException e) {
    showErrorMessage(e.getMessage());
    return null;
  }
  boolean overrideFlag = commandLine.hasOption(override.getOpt());

  List<String> argList = commandLine.getArgList();
  if (!commandLine.hasOption(inputFile.getOpt())) {
    return hbck.assigns(argList, overrideFlag);
  }
  List<String> assignmentList = new ArrayList<>();
  for (String filePath : argList) {
    try (InputStream fileStream = new FileInputStream(filePath)){
      LineIterator it = IOUtils.lineIterator(fileStream, "UTF-8");
      while (it.hasNext()) {
        assignmentList.add(it.nextLine().trim());
      }
    }
  }
  return hbck.assigns(assignmentList, overrideFlag);
}
 
Example 2
Source File: IntegrationTestWithCellVisibilityLoadAndVerify.java    From hbase with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void processOptions(CommandLine cmd) {
  List args = cmd.getArgList();
  if (args.size() > 0) {
    printUsage();
    throw new RuntimeException("No args expected.");
  }
  // We always want loadAndVerify action
  args.add("loadAndVerify");
  if (cmd.hasOption(USER_OPT)) {
    userNames = cmd.getOptionValue(USER_OPT);
  }
  super.processOptions(cmd);
}