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

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

Introduction

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

Prototype

public static OptionBuilder withLongOpt(String newLongopt) 

Source Link

Document

The next Option created will have the following long option value.

Usage

From source file:com.denimgroup.threadfix.cli.OptionsHolder.java

@SuppressWarnings("static-access")
public static Options getOptions() {
    Options options = new Options();

    Option property = OptionBuilder.withArgName("unsafe-ssl").hasArgs(1).withValueSeparator()
            .withDescription("unsafe-ssl to force ThreadFix to accept unsigned certificates.").create("D");
    options.addOption(property);//from  ww w .  j  a  v  a2  s.  c  om

    Option teams = OptionBuilder.withLongOpt("teams")
            .withDescription("Fetches a list of ThreadFix teams and applications.").create("t");
    options.addOption(teams);

    Option teamsPrettyPrint = OptionBuilder.withLongOpt("teamsPrettyPrint")
            .withDescription(
                    "Fetches a human readable list of ThreadFix teams, applications, and application IDs.")
            .create("tpp");
    options.addOption(teamsPrettyPrint);

    options.addOption(new Option("help", "Print this message"));

    Option set = OptionBuilder.withArgName("property> <value").hasArgs(2).withLongOpt("set")
            .withDescription("Set either the url (ThreadFix base url) or key (ThreadFix API key) properties")
            .create("s");
    options.addOption(set);

    Option search = OptionBuilder.hasOptionalArgs().withLongOpt("vulnerabilitySearch").withDescription(
            "Query the vulnerabilities using various optional parameters. More information can "
                    + "be found at https://github.com/denimgroup/threadfix/wiki/Threadfix-REST-Interface")
            .create("search");
    options.addOption(search);

    Option queueScan = OptionBuilder.withArgName("applicationId> <scannerName> <[scan profile Id]").hasArgs(3)
            .withLongOpt("queueScan")
            .withDescription("Queue a scan for the given applicationId with the given scanner type")
            .create("q");
    options.addOption(queueScan);

    Option addAppUrl = OptionBuilder.withArgName("applicationId> <appUrl").hasArgs(2).withLongOpt("addAppUrl")
            .withDescription("Add URL for the given applicationId").create("au");
    options.addOption(addAppUrl);

    Option setTaskConfig = OptionBuilder.withArgName("applicationId> <scannerName> <file").hasArgs(3)
            .withLongOpt("setTaskConfig")
            .withDescription(
                    "Save the scan configuration for the given applicationId with the given scanner type")
            .create("stc");
    options.addOption(setTaskConfig);

    Option setParameters = OptionBuilder.withArgName("appId> <frameworkType> <repositoryUrl").hasArgs(3)
            .withLongOpt("setParameters")
            .withDescription("Set scan parameters. Available parameters can be found with --printScanOptions")
            .create("sp");
    options.addOption(setParameters);

    options.addOption(new Option("printScanOptions", "Prints available scan options"));

    options.addOption(new Option("printScannerNames", "Prints scanner names supported by ScanAgent"));

    Option createTeam = OptionBuilder.withArgName("name").hasArg().withLongOpt("create-team")
            .withDescription("Creates a ThreadFix team and returns its JSON.").create("ct");
    options.addOption(createTeam);

    Option createApp = OptionBuilder.withArgName("teamId> <name> <url").hasArgs(3).withLongOpt("create-app")
            .withDescription("Creates a ThreadFix application and returns its JSON.").create("ca");
    options.addOption(createApp);

    Option createWaf = OptionBuilder.withArgName("name> <wafTypeName").hasArgs(2).withLongOpt("create-waf")
            .withDescription("Creates a ThreadFix WAF and returns its JSON.").create("cw");
    options.addOption(createWaf);

    Option searchTeam = OptionBuilder.withArgName("property> <value").hasArgs(2).withLongOpt("search-team")
            .withDescription("Searches for a ThreadFix team and returns its JSON.").create("st");
    options.addOption(searchTeam);

    Option searchWaf = OptionBuilder.withArgName("property> <value").hasArgs(2).withLongOpt("search-waf")
            .withDescription("Searches for a ThreadFix WAF and returns its JSON.").create("sw");
    options.addOption(searchWaf);

    Option searchApp = OptionBuilder.withArgName("property> <value1> <value2").hasArgs(3)
            .withLongOpt("search-app")
            .withDescription("Searches for a ThreadFix application and returns its JSON.").create("sa");
    options.addOption(searchApp);

    Option upload = OptionBuilder.withArgName("appId> <file").hasArgs(2).withLongOpt("upload")
            .withDescription("Uploads a scan to the specified application.").create("u");
    options.addOption(upload);

    Option getRules = OptionBuilder.withArgName("wafId").hasArg().withLongOpt("rules")
            .withDescription("Gets WAF Rules and returns its JSON.").create("r");
    options.addOption(getRules);

    Option getRulesForApp = OptionBuilder.withArgName("wafId> <applicationId").hasArgs(2)
            .withLongOpt("rules-for-application")
            .withDescription("Gets WAF Rules for an application and returns its JSON.").create("ra");
    options.addOption(getRulesForApp);

    Option createTag = OptionBuilder.withArgName("name> <[tagType]").hasArgs(2).withLongOpt("create-tag")
            .withDescription(
                    "Creates a ThreadFix Tag and returns its JSON. tagType is optional, default is Application Tag.")
            .create("ctg");
    options.addOption(createTag);

    Option searchTag = OptionBuilder.withArgName("property> <value").withValueSeparator(' ').hasArgs(2)
            .withLongOpt("search-tag")
            .withDescription("Searches for ThreadFix Tags by either name or id, and returns their JSON.")
            .create("stg");
    options.addOption(searchTag);

    Option updateTag = OptionBuilder.withArgName("tagId> <name").hasArgs(2).withLongOpt("update-tag")
            .withDescription("Update ThreadFix Tag, and returns their JSON.").create("utg");
    options.addOption(updateTag);

    Option removeTag = OptionBuilder.withArgName("tagId").hasArgs(1).withLongOpt("remove-tag")
            .withDescription("Remove ThreadFix Tag, and returns message.").create("rtg");
    options.addOption(removeTag);

    Option tags = OptionBuilder.withLongOpt("tags").withDescription("Fetches a list of ThreadFix tags.")
            .create("tg");
    options.addOption(tags);

    Option addAppTag = OptionBuilder.withArgName("applicationId> <tagId").withValueSeparator(' ').hasArgs(2)
            .withLongOpt("addAppTag").withDescription("Add Tag for the given applicationId").create("aat");
    options.addOption(addAppTag);

    Option removeAppTag = OptionBuilder.withArgName("applicationId> <tagId").withValueSeparator(' ').hasArgs(2)
            .withLongOpt("removeAppTag").withDescription("Remove Tag for the given applicationId")
            .create("rat");
    options.addOption(removeAppTag);

    Option addComment = OptionBuilder.withArgName("vulnId> <comment> <[commentTagIds]").hasArgs(3)
            .withLongOpt("add-comment")
            .withDescription("Add comment to a vulnerability. CommentTagIds is optional, separated by comma.")
            .create("ac");
    options.addOption(addComment);

    Option submitDefect = OptionBuilder.withArgName("applicationId> <[vulnerabilityIds]> <[*]").hasArgs(1)
            .hasOptionalArgs().withLongOpt("submit-defect")
            .withDescription("Submit a defect to the defect tracker configured for a specific application.")
            .create("sd");
    options.addOption(submitDefect);

    Option getDefectParameters = OptionBuilder.withArgName("applicationId>").hasArgs(1)
            .withLongOpt("get-defect-parameters")
            .withDescription("Get a list of parameters from the defect tracker given an application ID.")
            .create("gdp");
    options.addOption(getDefectParameters);

    return options;
}

From source file:cmdArgumentParser.CMDRetriever.java

public CMDRetriever(final String[] args) throws UnrecognizedOptionException {
    options.addOption(OptionBuilder.withLongOpt("ensembl_db")
            .withDescription("The ensembl database version to use. for example:\n"
                    + "ensembldb.ensembl.org:5306/homo_sapiens_core_83_38\n" + "for version 83")
            .hasArg().create("d"));
    options.addOption(OptionBuilder.withLongOpt("result_dir")
            .withDescription("The directory where the resulting dump should be placed in.\n" + "for version 83")
            .hasArg().create("r"));
}

From source file:com.comcast.oscar.cli.commands.CVC.java

/**
 * Set option parameters for command CVC
 * @return Option// w w  w . j  av a2s.c  o  m
 */
public static final Option OptionParameters() {
    OptionBuilder.withArgName("c/m=<filename>");
    OptionBuilder.hasArgs();
    OptionBuilder.hasOptionalArgs();
    OptionBuilder.withValueSeparator(' ');
    OptionBuilder.withLongOpt("certificate");
    OptionBuilder.withDescription("Add this CVC during file compilation. "
            + "For CoSigner use this format for the argument: c=<filename>. "
            + "For Manufacturer use this format for the argument: m=<filename>. "
            + "Both CVCs can be inserted simultaneously (space delimited).");
    return OptionBuilder.create("cvc");
}

From source file:com.comcast.oscar.cli.commands.DigitmapInsert.java

/**
 * Set option parameters for command Digitmap Insert
 * @return Option/*from  w ww  .  ja  v  a  2s .  co m*/
 */
public static final Option OptionParameters() {
    OptionBuilder.withArgName("[<filename>][<OID>]");
    OptionBuilder.hasArgs();
    OptionBuilder.hasOptionalArgs();
    OptionBuilder.withValueSeparator(' ');
    OptionBuilder.withLongOpt("digitmap");
    OptionBuilder.withDescription("Insert this DigitMap into a file when compiling - PacketCable ONLY. "
            + "Multiple DigitMaps can be inserted simultaneously (space delimited). " + "OID optional.");
    return OptionBuilder.create("dm");
}

From source file:fr.smartcontext.yatte.context.cli.DefaultOptionsProvider.java

/** 
 * {@inheritDoc}//  w w  w. j  av  a2  s.  c  o m
 * @see fr.smartcontext.yatte.context.cli.CLIOptionsProvider#getOptions()
 */
@Override
public Options getOptions() {
    Options options = new Options();
    OptionBuilder.withLongOpt(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_LONG_NAME);
    OptionBuilder.withDescription(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_DESCRIPTION);
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_ARGUMENT_NAME);
    options.addOption(OptionBuilder.create(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_NAME));

    OptionBuilder.withLongOpt(ApplicationParametersConstants.OUTPUT_OPTION_LONG_NAME);
    OptionBuilder.withDescription(ApplicationParametersConstants.OUTPUT_OPTION_DESCRIPTION);
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(ApplicationParametersConstants.OUTPUT_OPTION_ARGUMENT_NAME);
    OptionBuilder.isRequired();
    options.addOption(OptionBuilder.create(ApplicationParametersConstants.OUTPUT_OPTION_NAME));

    OptionBuilder.withLongOpt(ApplicationParametersConstants.TEMPLATE_OPTION_LONG_NAME);
    OptionBuilder.withDescription(ApplicationParametersConstants.TEMPLATE_OPTION_DESCRIPTION);
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(ApplicationParametersConstants.TEMPLATE_OPTION_ARGUMENT_NAME);
    OptionBuilder.isRequired();
    options.addOption(OptionBuilder.create(ApplicationParametersConstants.TEMPLATE_OPTION_NAME));

    return options;
}

From source file:edu.usc.qspr.Main.java

/**
 * Parses the inputs./*w  w w. j a v  a2s . c  o  m*/
 *
 * @param args the args
 */
@SuppressWarnings("static-access")
public static void parseInputs(String[] args) {
    Options options = new Options();

    options.addOption(OptionBuilder.withLongOpt("input").withDescription("QASM input file").hasArg()
            .withArgName("file").create("i"));

    options.addOption(OptionBuilder.withLongOpt("fabric").withDescription("Fabric specification").hasArg()
            .withArgName("file").create("f"));

    options.addOption(OptionBuilder.withLongOpt("output").withDescription("Quantum operation output file")
            .hasArg().withArgName("file").create("o"));

    options.addOption(OptionBuilder.withLongOpt("placement")
            .withDescription("Select a placement technique from {MVFB, MC, Center, and Baseline}.").hasArg()
            .withArgName("method").create("p"));

    options.addOption(OptionBuilder.withLongOpt("seed").withDescription("Random seed count").hasArg()
            .withArgName("#").create("s"));

    options.addOption(OptionBuilder.withLongOpt("verbose")
            .withDescription("Verbosely prints the quantum operations").create("v"));

    options.addOption(OptionBuilder.withLongOpt("debug").withDescription("Print debugging info").create("d"));

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    }

    if (!cmd.hasOption("input") || !cmd.hasOption("fabric") || !cmd.hasOption("placement")) {
        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(80);
        formatter.printHelp("qspr", "QSPR maps a given QASM "
                + "to a given PMD fabric. The resultant MCL file of " + "the mapped circuit will be generated.",
                options, "", true);

        System.exit(-1);
    }

    qasmFileAddr = cmd.getOptionValue("input");
    if (!new File(qasmFileAddr).exists()) {
        System.err.println("QASM file " + qasmFileAddr + " does not exist.");
        System.exit(-1);
    }

    fabricFileAddr = cmd.getOptionValue("fabric");
    if (!new File(fabricFileAddr).exists()) {
        System.err.println("Fabric file " + fabricFileAddr + " does not exist.");
        System.exit(-1);
    }

    placementMethod = cmd.getOptionValue("placement").toLowerCase();
    if (placementMethod.compareTo("mvfb") != 0 && placementMethod.compareTo("mc") != 0
            && placementMethod.compareTo("center") != 0 && placementMethod.compareTo("baseline") != 0) {
        System.err.println("Placement technique " + cmd.getOptionValue("placement")
                + " is not supported. Select from {MVFB, MC, Center, and Baseline}.");
        System.exit(-1);
    }

    if (placementMethod.compareTo("mvfb") == 0 || placementMethod.compareTo("mc") == 0) {
        if (!cmd.hasOption("seed")) {
            System.err.println("Number of random placements (seed #) is not specified.");
            System.exit(-1);
        } else {
            try {
                m = Integer.parseInt(placementMethod = cmd.getOptionValue("seed"));
            } catch (Exception e) {
                System.err.println("Seed \"" + cmd.getOptionValue("seed")
                        + "\" does not have a proper format. It should be an interger.");
                System.exit(-1);
            }
        }
    }

    if (cmd.hasOption("debug")) {
        RuntimeConfig.DEBUG = true;
    } else {
        RuntimeConfig.DEBUG = false;
    }

    if (cmd.hasOption("verbose")) {
        RuntimeConfig.VERBOSE = true;
    } else {
        RuntimeConfig.VERBOSE = false;
    }

    if (cmd.hasOption("output")) {
        RuntimeConfig.VERBOSE = true;
        RuntimeConfig.OUTPUT_TO_FILE = true;
        outputFileAddr = cmd.getOptionValue("output");
    } else {
        RuntimeConfig.OUTPUT_TO_FILE = false;
    }

}

From source file:com.comcast.oscar.cli.commands.Specification.java

/**
 * Set option parameters for command Specification
 * @return Option//from ww  w .ja v a  2  s. co  m
 */
public static final Option OptionParameters() {
    OptionBuilder.withArgName("d{ocsis}|p{acketcable}|d{po}e> <version");
    OptionBuilder.hasArgs();
    OptionBuilder.hasOptionalArgs();
    OptionBuilder.withValueSeparator(' ');
    OptionBuilder.withLongOpt("spec");
    OptionBuilder.withDescription(
            "Set specification and version of the file to be compiled/decompiled EX: -s d 1.1 (DOCSIS 1.1) / -s p 1.5 (PacketCable 1.5).");
    return OptionBuilder.create("s");
}

From source file:com.comcast.oscar.cli.commands.MergeBulk.java

/**
 * Set option parameters for command Maximum CPE
 * @return Option/*from   ww w  .j ava  2  s. c om*/
 */
public static final Option OptionParameters() {
    OptionBuilder.withArgName("input dirs> <o=<output dir>> <e=<extension>> <b{inary}/t{ext}");
    OptionBuilder.hasArgs();
    OptionBuilder.hasOptionalArgs();
    OptionBuilder.withValueSeparator(' ');
    OptionBuilder.withLongOpt("mergebulkbuild");
    OptionBuilder.withDescription("Merge multiple text files from directories into one binary. "
            + "EX: -mbb inputDirectoryModel inputDirectoryTier inputDirectoryCPE o=outputDirectory e=bin text. "
            + "Output directory, extension and b{inary}/t{ext} are optional.");
    return OptionBuilder.create("mbb");
}

From source file:jmxsh.SetCmd.java

private SetCmd() {
    opts = new Options();
    opts.addOption(OptionBuilder.withLongOpt("server").withDescription("Server containing mbean.")
            .withArgName("SERVER").hasArg().create("s"));

    opts.addOption(OptionBuilder.withLongOpt("mbean").withDescription("MBean containing attribute.")
            .withArgName("MBEAN").hasArg().create("m"));

    opts.addOption(// w ww .  j a  va 2  s .  c o m
            OptionBuilder.withLongOpt("help").withDescription("Display usage help.").hasArg(false).create("?"));
}

From source file:com.comcast.oscar.cli.commands.HexDisplay.java

/**
 * Set option parameters for command Hexidecimal display
 * @return Option/*from w  ww .java  2  s .c om*/
 */
public static final Option OptionParameters() {
    OptionBuilder.withArgName("t{oplevel}");
    OptionBuilder.hasArgs(1);
    OptionBuilder.hasOptionalArgs();
    OptionBuilder.withValueSeparator(' ');
    OptionBuilder.withLongOpt("hex");
    OptionBuilder.withDescription(
            "Display the hex of the input file. Option t creates a newline at the start of every top level TLV (binary files only).");
    return OptionBuilder.create("x");
}