Tabnine Logo
Options
Code IndexAdd Tabnine to your IDE (free)

How to use
Options
in
org.apache.commons.cli

Best Java code snippets using org.apache.commons.cli.Options (Showing top 20 results out of 9,855)

Refine searchRefine arrow

  • CommandLineParser
  • CommandLine
  • Option
  • OptionBuilder
  • HelpFormatter
  • ParseException
  • PosixParser
origin: stackoverflow.com

Options options = new Options();
Option input = new Option("i", "input", true, "input file path");
input.setRequired(true);
options.addOption(input);
Option output = new Option("o", "output", true, "output file");
output.setRequired(true);
options.addOption(output);
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
  cmd = parser.parse(options, args);
} catch (ParseException e) {
  System.out.println(e.getMessage());
  formatter.printHelp("utility-name", options);
String inputFilePath = cmd.getOptionValue("input");
String outputFilePath = cmd.getOptionValue("output");
origin: apache/kylin

public CubeMetaExtractor() {
  super();
  OptionGroup realizationOrProject = new OptionGroup();
  realizationOrProject.addOption(OPTION_CUBE);
  realizationOrProject.addOption(OPTION_PROJECT);
  realizationOrProject.addOption(OPTION_HYBRID);
  realizationOrProject.addOption(OPTION_All_PROJECT);
  realizationOrProject.setRequired(true);
  options.addOptionGroup(realizationOrProject);
  options.addOption(OPTION_INCLUDE_SEGMENTS);
  options.addOption(OPTION_INCLUDE_JOB);
  options.addOption(OPTION_INCLUDE_SEGMENT_DETAILS);
  options.addOption(OPTION_INCLUDE_ONLY_JOB_OUTPUT);
  options.addOption(OPTION_STORAGE_TYPE);
  options.addOption(OPTION_ENGINE_TYPE);
}
origin: alibaba/jstorm

private static Options buildGeneralOptions(Options opts) {
  Options r = new Options();
  for (Object o : opts.getOptions())
    r.addOption((Option) o);
  Option jar = OptionBuilder.withArgName("path").hasArg()
      .withDescription("topology jar of the submitted topology").create("jar");
  r.addOption(jar);
  Option conf = OptionBuilder.withArgName("configuration file").hasArg()
      .withDescription("an application configuration file").create("conf");
  r.addOption(conf);
  return r;
}
origin: apache/flink

static Options getListCommandOptions() {
  Options options = buildGeneralOptions(new Options());
  options.addOption(ALL_OPTION);
  options.addOption(RUNNING_OPTION);
  return options.addOption(SCHEDULED_OPTION);
}
origin: apache/flink

  /**
   * Merges the given {@link Options} into a new Options object.
   *
   * @param optionsA options to merge, can be null if none
   * @param optionsB options to merge, can be null if none
   * @return
   */
  public static Options mergeOptions(@Nullable Options optionsA, @Nullable Options optionsB) {
    final Options resultOptions = new Options();
    if (optionsA != null) {
      for (Option option : optionsA.getOptions()) {
        resultOptions.addOption(option);
      }
    }

    if (optionsB != null) {
      for (Option option : optionsB.getOptions()) {
        resultOptions.addOption(option);
      }
    }

    return resultOptions;
  }
}
origin: apache/flink

@Override
public void addRunOptions(Options baseOptions) {
  super.addRunOptions(baseOptions);
  for (Object option : allOptions.getOptions()) {
    baseOptions.addOption((Option) option);
  }
}
origin: FudanNLP/fnlp

Options opt = new Options();
opt.addOption("h", false, "Print help for this application");
opt.addOption("iter", true, "iterative num, default 50");
opt.addOption("c", true, "parameters 1, default 1");
if (args.length == 0 || cl.hasOption('h')) {
  HelpFormatter f = new HelpFormatter();
  f.printHelp(
      "Tagger:\n"
          + "ParserTrainer [option] train_file model_file;\n",
  return;
args = cl.getArgs();
String datafile = args[0];
String modelfile = args[1];
int maxite = Integer.parseInt(cl.getOptionValue("iter", "50"));
float c = Float.parseFloat(cl.getOptionValue("c", "1"));
origin: apache/hive

try {
 Options setPolicyOptions = new Options();
 Option pathOption = OptionBuilder.hasArg()
   .isRequired()
   .withLongOpt(pathOptionName)
   .withDescription("Path to set policy on")
   .create();
 setPolicyOptions.addOption(pathOption);
   .withDescription("Policy to set")
   .create();
 setPolicyOptions.addOption(policyOption);
 String path = args.getOptionValue(pathOptionName);
 String policy = args.getOptionValue(policyOptionName);
 writeTestOutput("Error parsing options for " + command + " " + pe.getMessage());
} catch (Exception e) {
 writeTestOutput("Caught exception running " + command + ": " + e.getMessage());
origin: apache/flink

public static void printHelpForInfo() {
  HelpFormatter formatter = new HelpFormatter();
  formatter.setLeftPadding(5);
  formatter.setWidth(80);
  System.out.println("\nAction \"info\" shows the optimized execution plan of the program (JSON).");
  System.out.println("\n  Syntax: info [OPTIONS] <jar-file> <arguments>");
  formatter.setSyntaxPrefix("  \"info\" action options:");
  formatter.printHelp(" ", getInfoOptionsWithoutDeprecatedOptions(new Options()));
  System.out.println();
}
origin: commons-cli/commons-cli

@Test
public void testShortWithoutEqual() throws Exception
{
  String[] args = new String[] { "-fbar" };
  Options options = new Options();
  options.addOption(OptionBuilder.withLongOpt("foo").hasArg().create('f'));
  CommandLine cl = parser.parse(options, args);
  assertEquals("bar", cl.getOptionValue("foo"));
}
origin: commons-cli/commons-cli

@Test
public void testUnambiguousPartialLongOption2() throws Exception
{
  String[] args = new String[] { "-ver" };
  
  Options options = new Options();
  options.addOption(OptionBuilder.withLongOpt("version").create());
  options.addOption(OptionBuilder.withLongOpt("help").create());
  
  CommandLine cl = parser.parse(options, args);
  
  assertTrue("Confirm --version is set", cl.hasOption("version"));
}
origin: apache/flume

private boolean parseCommandLineOpts(String[] args) throws ParseException {
 Options options = new Options();
 options.addOption("l", "dataDirs", true, "Comma-separated list of data " +
          "directories which the tool must verify. This option is mandatory")
     .addOption("h", "help", false, "Display help")
     .addOption("e", "eventValidator", true,
          "Fully Qualified Name of Event Validator Implementation");
 Option property = OptionBuilder.withArgName("property=value")
     .hasArgs(2)
     .withValueSeparator()
     .withDescription("custom properties")
     .create("D");
 options.addOption(property);
 CommandLine commandLine = parser.parse(options, args);
 if (commandLine.hasOption("help")) {
  new HelpFormatter().printHelp("bin/flume-ng tool fcintegritytool ", options, true);
  return false;
 if (!commandLine.hasOption("dataDirs")) {
  new HelpFormatter().printHelp("bin/flume-ng tool fcintegritytool ", "",
    options, "dataDirs is required.", true);
  return false;
 } else {
  String[] dataDirStr = commandLine.getOptionValue("dataDirs").split(",");
  for (String dataDir : dataDirStr) {
   File f = new File(dataDir);
origin: apache/storm

Options options = new Options();
options.addOption(Option.builder("h")
  .longOpt("help")
  .desc("Print a help message")
  .build());
options.addOption(Option.builder("t")
  .longOpt("test-time")
  .argName("MINS")
  .desc("How long to run the tests for in mins (defaults to " + TEST_EXECUTE_TIME_DEFAULT + ")")
  .build());
options.addOption(Option.builder()
  .longOpt("parallel")
  .argName("MULTIPLIER(:TOPO:COMP)?")
    + "(defaults to 1.0 no scaling)")
  .build());
options.addOption(Option.builder()
  .longOpt("throughput")
  .argName("MULTIPLIER(:TOPO:COMP)?")
    + "(defaults to 1.0 no scaling)")
  .build());
options.addOption(Option.builder()
  .longOpt("local-or-shuffle")
  .desc("replace shuffle grouping with local or shuffle grouping")
  .build());
options.addOption(Option.builder()
  .longOpt("imbalance")
origin: apache/zookeeper

private static TxnLogToolkit parseCommandLine(String[] args) throws TxnLogToolkitException, FileNotFoundException {
  CommandLineParser parser = new PosixParser();
  Options options = new Options();
  Option helpOpt = new Option("h", "help", false, "Print help message");
  options.addOption(helpOpt);
  Option recoverOpt = new Option("r", "recover", false, "Recovery mode. Re-calculate CRC for broken entries.");
  options.addOption(recoverOpt);
  Option quietOpt = new Option("v", "verbose", false, "Be verbose in recovery mode: print all entries, not just fixed ones.");
  options.addOption(quietOpt);
  Option dumpOpt = new Option("d", "dump", false, "Dump mode. Dump all entries of the log file with printing the content of a nodepath (default)");
  options.addOption(dumpOpt);
  Option forceOpt = new Option("y", "yes", false, "Non-interactive mode: repair all CRC errors without asking");
  options.addOption(forceOpt);
  Option chopOpt = new Option("c", "chop", false, "Chop mode. Chop txn file to a zxid.");
  Option zxidOpt = new Option("z", "zxid", true, "Used with chop. Zxid to which to chop.");
  options.addOption(chopOpt);
  options.addOption(zxidOpt);
    if (cli.getArgs().length < 1) {
      printHelpAndExit(1, options);
    if (cli.hasOption("chop") && cli.hasOption("zxid")) {
      return new TxnLogToolkit(cli.getArgs()[0], cli.getOptionValue("zxid"));
origin: commons-cli/commons-cli

@Test
public void testLs() throws Exception {
  // create the command line parser
  CommandLineParser parser = new PosixParser();
  Options options = new Options();
  options.addOption( "a", "all", false, "do not hide entries starting with ." );
  options.addOption( "A", "almost-all", false, "do not list implied . and .." );
  options.addOption( "b", "escape", false, "print octal escapes for nongraphic characters" );
  options.addOption( OptionBuilder.withLongOpt( "block-size" )
                  .withDescription( "use SIZE-byte blocks" )
                  .hasArg()
                  .withArgName("SIZE")
                  .create() );
  options.addOption( "B", "ignore-backups", false, "do not list implied entried ending with ~");
  options.addOption( "c", false, "with -lt: sort by, and show, ctime (time of last modification of file status information) with -l:show ctime and sort by name otherwise: sort by ctime" );
  options.addOption( "C", false, "list entries by columns" );
  String[] args = new String[]{ "--block-size=10" };
  CommandLine line = parser.parse( options, args );
  assertTrue( line.hasOption( "block-size" ) );
  assertEquals( line.getOptionValue( "block-size" ), "10" );
}
origin: apache/incubator-gobblin

private String parseConfigLocation(String[] args) {
 Options options = new Options();
 options.addOption(CLEANER_CONFIG);
 CommandLine cli;
 try {
  CommandLineParser parser = new DefaultParser();
  cli = parser.parse(options, Arrays.copyOfRange(args, 1, args.length));
 } catch (ParseException pe) {
  System.out.println("Command line parse exception: " + pe.getMessage());
  printUsage(options);
  throw new RuntimeException(pe);
 }
 return cli.getOptionValue(CLEANER_CONFIG.getOpt());
}
origin: galenframework/galen

public static GalenActionGenerateArguments parse(String[] args) {
  args = ArgumentsUtils.processSystemProperties(args);
  Options options = new Options();
  options.addOption("e", "export", true, "Path to generated spec file");
  options.addOption("G", "no-galen-extras", false, "Disable galen-extras expressions");
  CommandLineParser parser = new PosixParser();
  CommandLine cmd;
  try {
    cmd = parser.parse(options, args);
  } catch (MissingArgumentException e) {
    throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e);
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
  GalenActionGenerateArguments arguments = new GalenActionGenerateArguments();
  arguments.setExport(cmd.getOptionValue("e"));
  arguments.setUseGalenExtras(!cmd.hasOption("G"));
  if (cmd.getArgs() == null || cmd.getArgs().length < 1) {
    throw new IllegalArgumentException("Missing page dump file");
  }
  arguments.setPath(cmd.getArgs()[0]);
  return arguments;
}
origin: apache/incubator-gobblin

@Override
public void run(String[] args) {
 Options options = new Options();
 options.addOption(HELP);
 options.addOption(ZK);
 options.addOption(JOB_NAME);
 options.addOption(ROOT_DIR);
 options.addOption(WATCH);
  cli = parser.parse(options, Arrays.copyOfRange(args, 1, args.length));
 } catch (ParseException pe) {
  System.out.println( "Command line parse exception: " + pe.getMessage() );
  return;
 if (cli.hasOption(HELP.getOpt())) {
  printUsage(options);
  return;
 if (!cli.hasOption(JOB_NAME.getOpt())) {
  log.error("Need Job Name to be specified --", JOB_NAME.getLongOpt());
  throw new RuntimeException("Need Job Name to be specified");
 } else {
  jobName = cli.getOptionValue(JOB_NAME.getOpt());
  log.info("Using job name: {}", jobName);
origin: commons-cli/commons-cli

@Test
public void test15046() throws Exception
{
  CommandLineParser parser = new PosixParser();
  String[] CLI_ARGS = new String[] {"-z", "c"};
  Options options = new Options();
  options.addOption(new Option("z", "timezone", true, "affected option"));
  parser.parse(options, CLI_ARGS);
  
  //now add conflicting option
  options.addOption("c", "conflict", true, "conflict option");
  CommandLine line = parser.parse(options, CLI_ARGS);
  assertEquals( line.getOptionValue('z'), "c" );
  assertTrue( !line.hasOption("c") );
}
origin: runelite/runelite

public static void main(String[] args) throws IOException
  Options options = new Options();
  options.addOption("c", "cache", true, "cache base");
  options.addOption(null, "items", true, "directory to dump items to");
  options.addOption(null, "npcs", true, "directory to dump npcs to");
  options.addOption(null, "objects", true, "directory to dump objects to");
  options.addOption(null, "sprites", true, "directory to dump sprites to");
  try
    cmd = parser.parse(options, args);
    System.err.println("Error parsing command line options: " + ex.getMessage());
    System.exit(-1);
    return;
  String cache = cmd.getOptionValue("cache");
  if (cmd.hasOption("items"))
    String itemdir = cmd.getOptionValue("items");
org.apache.commons.cliOptions

Javadoc

Main entry-point into the library.

Options represents a collection of Option objects, which describe the possible options for a command-line.

It may flexibly parse long and short options, with or without values. Additionally, it may parse only a portion of a commandline, allowing for flexible multi-stage parsing.

Most used methods

  • addOption
  • <init>
    Construct a new Options descriptor
  • addOptionGroup
    Add the specified option group.
  • getOptions
    Retrieve a read-only list of options in this set
  • getOption
    Retrieve the named Option
  • hasOption
    Returns whether the named Option is a member of this Options.
  • getOptionGroup
    Returns the OptionGroup the opt belongs to.
  • helpOptions
    Returns the Options for use by the HelpFormatter.
  • toString
    Dump state, suitable for debugging.
  • getRequiredOptions
    Returns the required options as ajava.util.Collection.
  • addRequiredOption
    Add an option that contains a short-name and a long-name. The added option is set as required. It ma
  • getMatchingOptions
    Returns the options with a long name starting with the name specified.
  • addRequiredOption,
  • getMatchingOptions,
  • getOptionGroups,
  • hasLongOption,
  • hasShortOption,
  • add,
  • parse,
  • set,
  • setAction,
  • setChartOptions

Popular in Java

  • Updating database using SQL prepared statement
  • setContentView (Activity)
  • scheduleAtFixedRate (Timer)
  • getSystemService (Context)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • JList (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now