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

The following examples show how to use org.apache.commons.cli.OptionBuilder#withLongOpt() . 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: TaskomaticDaemon.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void createOption(Options accum, String longopt, boolean arg,
                          String argName, String description) {
    OptionBuilder.withArgName(argName);
    OptionBuilder.withLongOpt(longopt);
    OptionBuilder.hasArg(arg);
    OptionBuilder.withDescription(description);
    Option option = OptionBuilder.create(longopt);
    accum.addOption(option);
    if (this.masterOptionsMap.get(longopt) == null) {
        this.masterOptionsMap.put(longopt, option);
    }
}
 
Example 10
Source File: AddFind.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public AddFind()
{
	super("add", "a");

	OptionBuilder.withArgName("outputDir");
	OptionBuilder.withLongOpt("output");
	OptionBuilder.hasArg();
	OptionBuilder.withDescription("override default download directory");
	OptionBuilder.withType(File.class);
	getOptions().addOption( OptionBuilder.create('o') );
	getOptions().addOption("r", "recurse", false, "recurse sub-directories.");
	getOptions().addOption("f", "find", false, "only find files, don't add.");
	getOptions().addOption("h", "help", false, "display help about this command");
	getOptions().addOption("l", "list", false, "list previous find results");
}
 
Example 11
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 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: CliOption.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
Option toCliOption() {
    OptionBuilder.withArgName(fArgumentName);
    // Number of arguments
    if (fMaxArguments == 0) {
        // No arguments
        OptionBuilder.hasArg(false);
    } else if (fMaxArguments == 1) {
        // 1 argument, optional or mandatory
        if (fMinArguments == 0) {
            OptionBuilder.hasOptionalArg();
        } else {
            OptionBuilder.hasArg();
        }
    } else if (fMaxArguments < Integer.MAX_VALUE) {
        // Many arguments, optional or mandatory
        if (fMinArguments == 0) {
            OptionBuilder.hasOptionalArgs(fMaxArguments);
        } else {
            OptionBuilder.hasArgs(fMaxArguments);
        }
    } else {
        // Unbounded number of optional or mandatory arguments
        if (fMinArguments == 0) {
            OptionBuilder.hasOptionalArgs();
        } else {
            OptionBuilder.hasArgs();
        }
    }
    if (fLongOption != null) {
        OptionBuilder.withLongOpt(fLongOption);
    }
    if (fDescription != null) {
        OptionBuilder.withDescription(fDescription);
    }
    return Objects.requireNonNull(OptionBuilder.create(fShortOption));
}
 
Example 14
Source File: TaskomaticDaemon.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void createOption(Options accum, String longopt, boolean arg,
        String argName, String description) {
    OptionBuilder.withArgName(argName);
    OptionBuilder.withLongOpt(longopt);
    OptionBuilder.hasArg(arg);
    OptionBuilder.withDescription(description);
    Option option = OptionBuilder.create(longopt);
    accum.addOption(option);
    if (this.masterOptionsMap.get(longopt) == null) {
        this.masterOptionsMap.put(longopt, option);
    }
}
 
Example 15
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 16
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;
}