Java Code Examples for org.apache.commons.cli.OptionBuilder#isRequired()

The following examples show how to use org.apache.commons.cli.OptionBuilder#isRequired() . 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: OfflineEditsViewer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 *
 * @return command line options
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFilename");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFilename");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("v", "verbose", false, "");
  options.addOption("f", "fix-txids", false, "");
  options.addOption("r", "recover", false, "");
  options.addOption("h", "help", false, "");

  return options;
}
 
Example 2
Source File: OfflineImageViewer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFile");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("skipBlocks", false, "");
  options.addOption("printToScreen", false, "");
  options.addOption("delimiter", true, "");

  return options;
}
 
Example 3
Source File: OfflineImageViewerPB.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 */
private static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));

  options.addOption("o", "outputFile", true, "");
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("maxSize", true, "");
  options.addOption("step", true, "");
  options.addOption("addr", true, "");
  options.addOption("delimiter", true, "");
  options.addOption("t", "temp", true, "");

  return options;
}
 
Example 4
Source File: OfflineEditsViewer.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 *
 * @return command line options
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFilename");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFilename");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("v", "verbose", false, "");
  options.addOption("f", "fix-txids", false, "");
  options.addOption("r", "recover", false, "");
  options.addOption("h", "help", false, "");

  return options;
}
 
Example 5
Source File: OfflineImageViewer.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFile");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("skipBlocks", false, "");
  options.addOption("printToScreen", false, "");
  options.addOption("delimiter", true, "");

  return options;
}
 
Example 6
Source File: OfflineImageViewerPB.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 */
private static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));

  options.addOption("o", "outputFile", true, "");
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("maxSize", true, "");
  options.addOption("step", true, "");
  options.addOption("addr", true, "");
  options.addOption("delimiter", true, "");
  options.addOption("t", "temp", true, "");

  return options;
}
 
Example 7
Source File: OfflineEditsViewer.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 *
 * @return command line options
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFilename");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFilename");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("v", "verbose", false, "");
  options.addOption("h", "help", false, "");

  return options;
}
 
Example 8
Source File: OfflineImageViewer.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Build command-line options and descriptions
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFile");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("skipBlocks", false, "");
  options.addOption("printToScreen", false, "");
  options.addOption("delimiter", true, "");

  return options;
}
 
Example 9
Source File: AwAlerting.java    From adwords-alerting with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the command line options.
 *
 * @return the {@link Options}
 */
private static Options createCommandLineOptions() {
  Options options = new Options();

  OptionBuilder.withArgName("help");
  OptionBuilder.hasArg(false);
  OptionBuilder.withDescription("print this message");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("help"));

  OptionBuilder.withArgName("file");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("aw-report-alerting-sample.properties file.");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("file"));

  OptionBuilder.withArgName("accountIdsFile");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription(
      "Consider ONLY the account IDs specified on the file to run the report");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("accountIdsFile"));

  OptionBuilder.withArgName("debug");
  OptionBuilder.hasArg(false);
  OptionBuilder.withDescription("Will display all the debug information. "
      + "If the option 'verbose' is activated, "
      + "all the information will be displayed on the console as well");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("debug"));

  return options;
}
 
Example 10
Source File: UpdateGroups.java    From ade with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method for building the allowed options.
 * @param options Options object for adding the options created with OptionBuilder.
 */
private void buildOptions(Options options){        
    OptionBuilder.withArgName(OPTION_HELP);
    OptionBuilder.withLongOpt(OPTION_HELP);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Print help message and exit.");
    options.addOption(OptionBuilder.create('h'));
    
    OptionBuilder.withArgName(OPTION_INPUT_JSON);
    OptionBuilder.withLongOpt(OPTION_INPUT_JSON);
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Specify the JSON input file.");
    options.addOption(OptionBuilder.create("j"));
}
 
Example 11
Source File: Upload.java    From ade with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method to parse specific arguments for "Upload".
 * 
 * @throws AdeException 
 * 
 */
protected final void parseArgs(String[] args) throws AdeException {
    final Options options = new Options();

    OptionBuilder.withArgName(OPTION_DUMP_PARSE_REPORT);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Specify this option to generate parse report");
    options.addOption(OptionBuilder.create(OPTION_DUMP_PARSE_REPORT));

    final CommandLine line = super.parseArgs(options, args);

    if (line.hasOption(OPTION_DUMP_PARSE_REPORT)) {
        getAdeExtProperties().setParseReportRequested(true);
    }
}
 
Example 12
Source File: Analyze.java    From ade with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method to parse specific arguments for "Analyze".
 */
@Override
protected final void parseArgs(String[] args) throws AdeException {
    final Options options = new Options();

    OptionBuilder.withArgName(OPTION_SOURCES);
    OptionBuilder.withLongOpt(OPTION_SOURCES);
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Specify the Source to be analyzed.  ");
    options.addOption(OptionBuilder.create("s"));

    super.parseArgs(options, args);

}
 
Example 13
Source File: Server.java    From usergrid with Apache License 2.0 5 votes vote down vote up
static Options createOptions() {
    // the nogui option will be required due to combining the graphical
    // launcher with this standalone CLI based server
    Options options = new Options();
    OptionBuilder.withDescription( "Start launcher without UI" );
    OptionBuilder.isRequired( true );
    Option noguiOption = OptionBuilder.create( "nogui" );

    OptionBuilder.isRequired( false );
    OptionBuilder.withDescription( "Initialize database" );
    Option initOption = OptionBuilder.create( "init" );

    OptionBuilder.withDescription( "Start database" );
    Option dbOption = OptionBuilder.create( "db" );

    OptionBuilder.withDescription( "Http port (without UI)" );
    OptionBuilder.hasArg();
    OptionBuilder.withArgName( "PORT" );
    OptionBuilder.withLongOpt( "port" );
    OptionBuilder.withType( Number.class );
    Option portOption = OptionBuilder.create( 'p' );

    options.addOption( initOption );
    options.addOption( dbOption );
    options.addOption( portOption );
    options.addOption( noguiOption );

    return options;
}
 
Example 14
Source File: AdeExtOptions.java    From ade with GNU General Public License v3.0 4 votes vote down vote up
public static Options buildOptions(Options subClassOptions) {
    /* Add the options from subClass */
    Options options = new Options();
    for (Object subClassOption : subClassOptions.getOptions()) {
        Option option = (Option) subClassOption;
        options.addOption(option);
    }

    /* Add the general options */
    OptionBuilder.withArgName(OPTION_HELP);
    OptionBuilder.withLongOpt(OPTION_HELP);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Print help message and exit");
    options.addOption(OptionBuilder.create('h'));

    OptionBuilder.withArgName(OPTION_INPUT_FILE);
    OptionBuilder.withLongOpt(OPTION_INPUT_FILE);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Input file name or 'stdin'");
    options.addOption(OptionBuilder.create('f'));

    OptionBuilder.withArgName(OPTION_INPUT_DIR);
    OptionBuilder.withLongOpt(OPTION_INPUT_DIR);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Input dir name");
    options.addOption(OptionBuilder.create('d'));

    OptionBuilder.withArgName(OPTION_SOURCES);
    OptionBuilder.withLongOpt(OPTION_SOURCES);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Source Names.");
    options.addOption(OptionBuilder.create('s'));

    OptionBuilder.withArgName(OPTION_OS_TYPE);
    OptionBuilder.withLongOpt(OPTION_OS_TYPE);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("The OS Type."
            + "If this option is omitted, the default is Linux");
    options.addOption(OptionBuilder.create('o'));

    OptionBuilder.withArgName(OPTION_GMT_OFFSET);
    OptionBuilder.withLongOpt(OPTION_GMT_OFFSET);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("hours offset from GMT");
    options.addOption(OptionBuilder.create('g'));

    return options;
}