Example usage for org.apache.commons.cli OptionBuilder hasArg

List of usage examples for org.apache.commons.cli OptionBuilder hasArg

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder hasArg.

Prototype

public static OptionBuilder hasArg(boolean hasArg) 

Source Link

Document

The next Option created will require an argument value if hasArg is true.

Usage

From source file:org.structnetalign.util.NetworkCombiner.java

private static Options getOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "Required. The probability of including an interactor. Interactions associated with an excluded interactor will be removed.")
            .isRequired(true).create("probability"));
    options.addOption(/*from  w  w w  .  j  a  v  a2s  .  c  o m*/
            OptionBuilder.hasArg(false).withDescription("Require each interactor to have a PDB structure")
                    .isRequired(false).create("require_pdb"));
    options.addOption(
            OptionBuilder.hasArg(false).withDescription("Require each interactor to have a SCOP domain")
                    .isRequired(false).create("require_scop"));
    options.addOption(
            OptionBuilder.hasArg(false).withDescription("Require each interactor to have a FASTA sequence")
                    .isRequired(false).create("require_fasta"));
    options.addOption(OptionBuilder.hasArg(false).withDescription("Remove all interactors with no interactions")
            .isRequired(false).create("remove_lonely"));
    options.addOption(
            OptionBuilder.hasArg(false).withDescription("Require each interactor to have a Pfam entry")
                    .isRequired(false).create("require_pfam"));
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "The directory containing cached PDB files. Defaults to the AtomCache default, which is probably in your system's temporary directory (e.g. /tmp). It is okay if this is an empty directory, but the directory must exist.")
            .isRequired(false).create("pdb_dir"));
    options.addOption(OptionBuilder.hasArg(true).withDescription("Required. The output PSI-MI25 XML file.")
            .isRequired(true).create("output"));
    return options;
}

From source file:org.vivoweb.harvester.util.args.ArgParser.java

/**
 * Create the Options from this ArgParser
 *///from w  w w  .j a va 2 s  .  c o  m
@SuppressWarnings("static-access")
private void createOptions() {
    this.parser = new Options();
    for (ArgDef arg : getArgDefs()) {
        OptionBuilder ob = OptionBuilder.isRequired(false);
        if (arg.getLongOption() != null) {
            ob = ob.withLongOpt(arg.getLongOption());
            this.optMap.put(arg.getLongOption(), arg);
        }
        if (arg.getDescription() != null) {
            ob = ob.withDescription(arg.getDescription());
        }
        if (arg.hasParameter()) {
            ob = ob.withArgName(arg.getParameterDescription());
            int num = arg.numParameters();
            if (num == 1) {
                ob = ob.hasArg(arg.isParameterRequired());
            } else if (num == -1) {
                if (arg.isParameterRequired()) {
                    ob = ob.hasArgs();
                } else {
                    if (arg.isParameterValueMap()) {
                        ob = ob.hasOptionalArgs(2).withValueSeparator();
                    } else {
                        ob = ob.hasOptionalArgs();
                    }
                }
            } else {
                if (arg.isParameterRequired()) {
                    ob = ob.hasArgs(num);
                } else {
                    ob = ob.hasOptionalArgs(num);
                }
            }
        }
        Option o;
        if (arg.getShortOption() != null) {
            o = ob.create(arg.getShortOption().charValue());
            this.optMap.put(arg.getShortOption().toString(), arg);
        } else {
            o = ob.create();
        }
        this.parser.addOption(o);
    }
}