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:gov.llnl.lc.smt.command.SmtCommand.java

/**
 * Set up the options for writing files that contain "single" instances of the
 * fabric. This is the most common type of writing.
 * //ww w.jav a 2s .co  m
 * @see describe related java objects
 * 
 * @return
 ***********************************************************/
protected boolean initWriteFileOptions() {
    // initialize the command specific options
    SmtProperty sp = SmtProperty.SMT_WRITE_OMS;
    Option woFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    /* support writing of both OMS and Fabric files */
    //    sp = SmtProperty.SMT_WRITE_FABRIC;
    //    Option wfFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName())
    //        .withValueSeparator('=').withDescription(sp.getDescription()).withLongOpt(sp.getName())
    //        .create(sp.getShortName());

    options.addOption(woFile);
    //    options.addOption(wfFile);

    return true;
}

From source file:gov.llnl.lc.smt.command.SmtCommand.java

/**
 * Set up the options for writing the Fabric Config files, currently
 * this means the ibfabricconf.xml and node-name-map files.
 * /*from   w  w w  .  ja  v a2 s  . c  om*/
 * @see describe related java objects
 * 
 * @return
 ***********************************************************/
protected boolean initWriteConfigFileOptions() {
    // initialize the command specific options
    SmtProperty sp = SmtProperty.SMT_WRITE_CONFIG;
    Option wcFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    options.addOption(wcFile);

    return true;
}

From source file:gov.llnl.lc.smt.command.event.SmtEvent.java

/**
 * Describe the method here/*from w w  w.  jav  a 2s .  co m*/
 *
 * @see gov.llnl.lc.smt.command.SmtCommand#init()
 * @see gov.llnl.lc.smt.command.SmtCommand#initCommonOptions()
 *
 * @return
 ***********************************************************/

@Override
public boolean init() {
    USAGE = "[-h=<host url>] [-pn=<port num>] -sr";
    HEADER = "smt-event - a tool for obtaining event information";
    EXAMPLE = "examples:" + SmtConstants.NEW_LINE + "> smt-event -pn 10013" + SmtConstants.NEW_LINE
            + "> smt-event -pn 10013 -sr" + SmtConstants.NEW_LINE + "> smt-event -rH surface3h.his -dump 10"
            + SmtConstants.NEW_LINE + "> smt-event -q events" + SmtConstants.NEW_LINE
            + "> smt-event -rH surface3h.his -q status" + SmtConstants.NEW_LINE + "."; // terminate with nl

    // create and initialize the common options for this command
    initCommonOptions();

    // add non-common options
    initMulitReadFileOptions(); // read the remainder of the file types

    SmtProperty sp = SmtProperty.SMT_QUERY_TYPE;
    Option qType = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_QUERY_LIST;
    Option qList = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription());

    sp = SmtProperty.SMT_DUMP;
    Option dump = OptionBuilder.hasOptionalArg().withDescription(sp.getDescription()).withLongOpt(sp.getName())
            .create(sp.getShortName());

    sp = SmtProperty.SMT_STATUS;
    Option status = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName())
            .create(sp.getShortName());

    options.addOption(status);
    options.addOption(qType);
    options.addOption(qList);
    options.addOption(dump);

    return true;
}

From source file:gov.llnl.lc.smt.command.route.SmtPartition.java

/**
 * Describe the method here/*  ww w  .  j  av a 2s .  c  o  m*/
 *
 * @see gov.llnl.lc.smt.command.SmtCommand#init()
 * @see gov.llnl.lc.smt.command.SmtCommand#initCommonOptions()
 *
 * @return
 ***********************************************************/

@Override
public boolean init() {
    USAGE = "[-h=<host url>] [-pn=<port num>] ";
    HEADER = "smt-partition - examine partition attributes";
    EXAMPLE = "examples:" + SmtConstants.NEW_LINE + "> smt-partition -pn 10011 -q status"
            + SmtConstants.NEW_LINE + "> smt-partition -pn 10013 -q pkey 0x7fff" + SmtConstants.NEW_LINE
            + "> smt-partition -rH surface3h.his -q member 0xf452:1403:0034:2ea1" + SmtConstants.NEW_LINE + "."; // terminate with nl

    // create and initialize the common options for this command
    initCommonOptions();

    // add non-common options
    initMulitReadFileOptions(); // read the remainder of the file types

    SmtProperty sp = SmtProperty.SMT_QUERY_TYPE;
    Option qType = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_QUERY_LIST;
    Option qList = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription());

    sp = SmtProperty.SMT_STATUS;
    Option status = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName())
            .create(sp.getShortName());

    sp = SmtProperty.SMT_DUMP;
    Option dump = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName())
            .create(sp.getShortName());

    options.addOption(status);
    options.addOption(qType);
    options.addOption(qList);
    options.addOption(dump);

    return true;
}

From source file:gov.llnl.lc.smt.command.search.SmtIdentification.java

/**
 * Describe the method here//from   w ww  . j a  va2  s . co  m
 *
 * @see gov.llnl.lc.smt.command.SmtCommand#init()
 * @see gov.llnl.lc.smt.command.SmtCommand#initCommonOptions()
 *
 * @return
 ***********************************************************/

@Override
public boolean init() {
    USAGE = "[-h=<host url>] [-pn=<port num>] <ID string> [-p=<node port #>]";
    HEADER = "smt-id - an identification tool.  Provide a guid, lid, pkey, mlid, or name as an ID string";
    EXAMPLE = "examples:" + SmtConstants.NEW_LINE
            + "> smt-id -pn 10011 374                  - identifies and describes lid 374"
            + SmtConstants.NEW_LINE
            + "> smt-id 0006:6a01:e800:1313 -pn 10013  - identifies and describes the guid"
            + SmtConstants.NEW_LINE
            + "> smt-id -pn 10013 0xc003               - identifies and describes the mlid"
            + SmtConstants.NEW_LINE
            + "> smt-id -rH surface3h.his 0x7fff       - identifies and describes the pkey"
            + SmtConstants.NEW_LINE + "."; // terminate with nl

    // create and initialize the common options for this command
    initCommonOptions();

    SmtProperty sp = SmtProperty.SMT_ID_PORT;
    Option port = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    options.addOption(port);
    return true;
}

From source file:gov.llnl.lc.smt.command.file.SmtFile.java

/**
 * Initializes the resources for the Command, primarily the Option
 * object.//w  ww  .j  a v  a 2  s  .  c o m
 *
 * @see gov.llnl.lc.smt.command.SmtCommand#init()
 *
 * @return
 ***********************************************************/

@Override
public boolean init() {
    USAGE = "filename [-t] [-i] [-c <# skip> <out filename>]";
    HEADER = "smt-file - SMT file interrogation and manipulation";
    EXAMPLE = "examples:" + SmtConstants.NEW_LINE
            + "> smt-file -i surface3h.his                  - show surface3h.his details"
            + SmtConstants.NEW_LINE
            + "> smt-file -i HypeFR.his -lts                - show HypeFR.his details, including timestamps"
            + SmtConstants.NEW_LINE
            + "> smt-file surface3h.his -c 4 compress.his   - compress surface3h.his 4x and write to compress.his"
            + SmtConstants.NEW_LINE
            + "> smt-file sierra3H.his -x Feb 25 12:35:08 2015 Feb 25 13:52:38 2015 sierraSmall.his"
            + SmtConstants.NEW_LINE
            + ".                                            - extract snapshots from sierra3H.his (t1 to t2) and write to sierraSmall.his"
            + SmtConstants.NEW_LINE + "."; // terminate with nl

    // create and initialize the common options for this command
    initMinimumOptions();

    // initialize the command specific options
    SmtProperty sp = SmtProperty.SMT_FILE_TYPE;
    Option fType = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription());
    sp = SmtProperty.SMT_FILE_INFO;
    Option info = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription());
    sp = SmtProperty.SMT_FILE_COMPRESS;
    Option compress = OptionBuilder.hasArg(true).hasArgs(2).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());
    sp = SmtProperty.SMT_CONCAT_HISTORY;
    Option concat = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());
    sp = SmtProperty.SMT_FILE_EXTRACT;
    Option extract = OptionBuilder.hasArg(true).hasArgs(9).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());
    sp = SmtProperty.SMT_LIST_TIMESTAMP;
    Option lTimeStamps = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription());
    sp = SmtProperty.SMT_FILE_FILTER;
    Option fF = OptionBuilder.hasArg(true).hasArgs(2).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    options.addOption(fType);
    options.addOption(info);
    options.addOption(compress);
    options.addOption(concat);
    options.addOption(extract);
    options.addOption(lTimeStamps);
    options.addOption(fF);

    return true;
}

From source file:gov.llnl.lc.smt.command.SmtCommand.java

/**
 * Set up the options for writing files that contain "multiple" instances of
 * the fabric. Tools that write these types of files are less common.
 * //from  w w w.jav  a  2s  .  c o m
 * 
 * @see describe related java objects
 * 
 * @return
 ***********************************************************/
protected boolean initMultiWriteFileOptions() {
    // initialize the command specific options
    SmtProperty sp = SmtProperty.SMT_WRITE_DELTA;
    Option wdFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    /* support writing of both OMS and Fabric files */
    sp = SmtProperty.SMT_WRITE_DELTA_HISTORY;
    Option wdhFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    /* support writing of both OMS and Fabric files */
    sp = SmtProperty.SMT_WRITE_OMS_HISTORY;
    Option woFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    // the recording attributes (only applies when in the History writing mode)
    sp = SmtProperty.SMT_HISTORY_RECORDS;
    Option nRecords = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_HISTORY_MINUTES;
    Option nMinutes = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_HISTORY_HOURS;
    Option nHours = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    //    options.addOption(woFile);
    //    options.addOption(wdFile);
    options.addOption(wdhFile);

    options.addOption(nRecords);
    options.addOption(nMinutes);
    options.addOption(nHours);

    return true;
}

From source file:gov.llnl.lc.smt.command.route.SmtRoute.java

/**
 * Describe the method here/*from w  w  w.  j  a  v a  2 s.  co  m*/
 *
 * @see gov.llnl.lc.smt.command.SmtCommand#init()
 *
 * @return
 ***********************************************************/

@Override
public boolean init() {
    USAGE = "[-h=<host url>] [-pn=<port num>] ";
    HEADER = "smt-route - a tool for obtaining routing information (similar to ibroute and ibtracert)";
    EXAMPLE = "examples:" + SmtConstants.NEW_LINE
            + "> smt-route -pn 10011 -sr                    - provide routing attributes of the fabric"
            + SmtConstants.NEW_LINE
            + "> smt-route -pn 10013 -q switches            - list all of the switches that contain port routes"
            + SmtConstants.NEW_LINE
            + "> smt-route -q table 0006:6a00:ec00:2d00     - show the switches (specified by guid) routing table by port #"
            + SmtConstants.NEW_LINE
            + "> smt-route -q routes 0006:6a00:ec00:2d00 24 - show the routes through port 24 of that switch"
            + SmtConstants.NEW_LINE
            + "> smt-route -pn 10013 -q path 374 112        - show the path (trace route) from lid 374 to lid 112"
            + SmtConstants.NEW_LINE
            + "> smt-route -rH surface3h.his -dump          - dump all information about all the routes"
            + SmtConstants.NEW_LINE + "."; // terminate with nl

    // create and initialize the common options for this command
    //    initConnectionOptions();
    initCommonOptions();

    /*
     * for most of these commands, a OSM_Fabric and an RT_Table is needed
     * 
     * -rR  read the routing table from a file
     * -pn  read the OMS, and therefore the fabric from a connection
     * 
     * -path | -route  do the path or route (path has preference)
     * 
     * -G  guids will be specified (one for route, src & dst for path)
     * -L  lids will be specified  (one for route, src & dst for path)
     * 
     * -wR  write the routing table to a file
     *         (generates the table, and saves it to a file)
     *         
     * -i  info about the routing table
     */

    //    // add non-common options
    //

    // initialize the command specific options
    SmtProperty sp = SmtProperty.SMT_QUERY_TYPE;
    Option qType = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_QUERY_LIST;
    Option qList = new Option(sp.getShortName(), sp.getName(), false, sp.getDescription());

    sp = SmtProperty.SMT_STATUS;
    Option status = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName())
            .create(sp.getShortName());

    sp = SmtProperty.SMT_DUMP;
    Option dump = OptionBuilder.hasArg(false).withDescription(sp.getDescription()).withLongOpt(sp.getName())
            .create(sp.getShortName());

    options.addOption(qType);
    options.addOption(qList);
    options.addOption(status);
    options.addOption(dump);
    return true;
}

From source file:com.dumontierlab.pdb2rdf.Pdb2Rdf.java

@SuppressWarnings("static-access")
private static Options createOptions() {
    Options options = new Options();

    options.addOption("help", false, "Print this message");
    Option formatOption = OptionBuilder.withArgName("RDF/XML|N-TRIPLE|N3|NQUADS").hasOptionalArgs(1)
            .withDescription("RDF output format (default: RDF/XMl)").hasArg(true).create("format");
    options.addOption(formatOption);//from w ww .j av a  2 s  . c om
    Option dirOption = OptionBuilder.withArgName("path")
            .withDescription("Directory where input files are located").hasArg(true).create("dir");
    options.addOption(dirOption);
    Option clusterOption = OptionBuilder.withArgName("URL")
            .withDescription("URL of the cluster head where input will be acquired").hasArg(true)
            .create("cluster");
    options.addOption(clusterOption);

    Option fileOption = OptionBuilder.withArgName("path").withDescription("Input file").hasArg(true)
            .create("file");
    options.addOption(fileOption);
    options.addOption("gzip", false, "Input is given as gzip file(s)");
    Option outDirOption = OptionBuilder.withArgName("path")
            .withDescription("Directory where output RDF files will be created").hasArg(true).create("out");
    options.addOption(outDirOption);
    options.addOption("ontology", false, "Prints the ontology for the PDB namespace");
    Option threadsOption = OptionBuilder.withArgName("number")
            .withDescription("Number of threads (default: number of processing units * 2)").hasArg(true)
            .create("threads");
    options.addOption(threadsOption);

    options.addOption("stats", false,
            "Outputs statistics to file pdb2rdf-stats.txt (in output directory, if one is specified, or in the current directory otherwise)");
    options.addOption("statsFromRDF", false,
            "Generates statistics from RDF files (located in the directory spefied by -dir). The stats are output to the file pdb2rdf-stats.txt (in output directory, if one is specified, or in the current directory otherwise)");
    Option noAtomSitesOption = OptionBuilder.hasArg(true)
            .withDescription("Specify detail level: COMPLETE | ATOM | RESIDUE | EXPERIMENT | METADATA ")
            .create("detailLevel");
    options.addOption(noAtomSitesOption);
    return options;
}

From source file:gov.llnl.lc.smt.command.SmtCommand.java

/**
 * Set up the options for writing files that contain "multiple" instances of
 * the OMS. Tools that write these types of files are MOST common.
 * //from   w  w w .  java2 s  . c  o  m
 * 
 * @see describe related java objects
 * 
 * @return
 ***********************************************************/
protected boolean initWriteHistoryFileOptions() {
    // initialize the command specific options

    SmtProperty sp = SmtProperty.SMT_WRITE_OMS_HISTORY;
    Option woFile = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    // the recording attributes (only applies when in the History writing mode)
    sp = SmtProperty.SMT_HISTORY_RECORDS;
    Option nRecords = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_HISTORY_MINUTES;
    Option nMinutes = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    sp = SmtProperty.SMT_HISTORY_HOURS;
    Option nHours = OptionBuilder.hasArg(true).hasArgs(1).withArgName(sp.getArgName()).withValueSeparator('=')
            .withDescription(sp.getDescription()).withLongOpt(sp.getName()).create(sp.getShortName());

    options.addOption(woFile);

    options.addOption(nRecords);
    options.addOption(nMinutes);
    options.addOption(nHours);

    return true;
}