Example usage for org.apache.commons.cli Option setArgs

List of usage examples for org.apache.commons.cli Option setArgs

Introduction

In this page you can find the example usage for org.apache.commons.cli Option setArgs.

Prototype

public void setArgs(int num) 

Source Link

Document

Sets the number of argument values this Option can take.

Usage

From source file:org.duracloud.chunk.FileChunkerDriver.java

private static Options getOptions() {

    Option username = new Option("u", "username", true, "username of duracloud instance");
    username.setArgs(1);
    username.setArgName("username");

    Option password = new Option("p", "password", true, "password of duracloud instance");
    password.setArgs(1);//from  w  w  w  .  ja  va2  s.c  o m
    password.setArgName("password");

    Option create = new Option("g", "generate", true, "generate test data to <outFile> of " + "<size> bytes");
    create.setArgs(2);
    create.setArgName("outFile numBytes");
    create.setValueSeparator(' ');

    Option add = new Option("a", "add", true,
            "add content from dir:<f> to space:<t> of max" + " chunk size:<s> in units of K,M,G");
    add.setArgs(3);
    add.setArgName("f t s{K|M|G}");
    add.setValueSeparator(' ');

    Option fileFiltered = new Option("f", "file-filter", true,
            "limit processed files to those " + "listed in file-list:<l>");
    fileFiltered.setArgs(1);
    fileFiltered.setArgName("l");

    Option dirFiltered = new Option("d", "dir-filter", true,
            "limit processed directories to " + "those listed in file-list:<l>");
    dirFiltered.setArgs(1);
    dirFiltered.setArgName("l");

    Option cloud = new Option("c", "cloud-store", true,
            "use cloud store found at <host>:<port> " + "as content dest");
    cloud.setArgs(2);
    cloud.setArgName("host:port");
    cloud.setValueSeparator(':');

    Option excludeChunkMD5s = new Option("x", "exclude-chunk-md5s", false,
            "if this option is set, chunk " + "MD5s will NOT be preserved " + "in the manifest");

    Option ignoreLargeFiles = new Option("i", "ignore-large-files", false, "if this option is set, files "
            + "over the chunk size " + "specified in the 'add' " + "option will be ignored.");

    Options options = new Options();
    options.addOption(username);
    options.addOption(password);
    options.addOption(create);
    options.addOption(add);
    options.addOption(fileFiltered);
    options.addOption(dirFiltered);
    options.addOption(cloud);
    options.addOption(excludeChunkMD5s);
    options.addOption(ignoreLargeFiles);

    return options;
}

From source file:org.duracloud.mill.ltp.bit.LoopingBitIntegrityTaskProducerCommandLineOptions.java

/**
 * // www  .  j a va  2  s.  c o m
 */
public LoopingBitIntegrityTaskProducerCommandLineOptions() {
    super();
    Option exlucsionsList = new Option(EXCLUSION_LIST_OPTION, "exclusion-list", true,
            "A file containing exclusions as regular expressions, one expression per line."
                    + "Expressions will be matched against the following path: /{account}/{storeId}/{spaceId}");
    exlucsionsList.setArgs(1);
    exlucsionsList.setArgName("file");
    addOption(exlucsionsList);

    Option inclusionList = new Option(INCLUSION_LIST_OPTION, "inclusion-list", true,
            "A file containing inclusions as regular expressions, one expression per line."
                    + "Expressions will be matched against the following path: /{account}/{storeId}/{spaceId}");
    inclusionList.setArgs(1);
    inclusionList.setArgName("file");
    addOption(inclusionList);

}

From source file:org.duracloud.mill.ltp.dup.DuplicationOptions.java

public DuplicationOptions() {
    super();/*w w  w  . ja  v  a2 s  .c o m*/

    Option localDuplicationDir = new Option(LOCAL_DUPLICATION_DIR_OPTION, "local-duplication-dir", true,
            "Indicates that a local duplication policy " + "directory should be used.");
    localDuplicationDir.setArgs(1);
    localDuplicationDir.setArgName("file");
    addOption(localDuplicationDir);

    Option policyBucketSuffix = new Option(POLICY_BUCKET_SUFFIX, "policy-bucket-suffix", true,
            "The last portion of the name of the S3 bucket where " + "duplication policies can be found.");
    policyBucketSuffix.setRequired(false);
    addOption(policyBucketSuffix);

}

From source file:org.duracloud.mill.taskproducertool.Driver.java

private static Options getOptions() {
    Options options = new Options();
    Option subdomain = new Option("s", "subdomain", true, "A duracloud subdomain");
    subdomain.setArgs(1);
    subdomain.setArgName("subdomain");
    subdomain.setRequired(true);/*  w ww  .  j a v a 2 s.c  om*/
    options.addOption(subdomain);

    Option queue = new Option("q", "queue", true, "A task queue name");
    queue.setArgs(1);
    queue.setArgName("queue");
    queue.setRequired(true);
    options.addOption(queue);

    Option username = new Option("u", "username", true, "The queue service username");
    username.setArgs(1);
    username.setArgName("username");
    options.addOption(username);

    Option password = new Option("p", "password", true, "The queue service password");
    password.setArgs(1);
    password.setArgName("password");
    options.addOption(password);

    Option type = new Option("t", "type", true, "The type of operation: NOOP, DUP, BIT, AUDIT");
    type.setArgs(1);
    type.setArgName("type");
    type.setRequired(true);
    options.addOption(type);

    Option sourceStorageProviderId = new Option("a", "source-provider-id", true,
            "The id of the source storage provider");
    sourceStorageProviderId.setArgs(1);
    sourceStorageProviderId.setArgName("id");
    options.addOption(sourceStorageProviderId);

    Option destStorageProviderId = new Option("b", "dest-provider-id", true,
            "The id of the destination storage provider");
    destStorageProviderId.setArgs(1);
    destStorageProviderId.setArgName("id");
    options.addOption(destStorageProviderId);

    Option spaceId = new Option("d", "space-id", true, "The id of the space");
    spaceId.setArgs(1);
    spaceId.setArgName("spaceId");
    options.addOption(spaceId);

    Option contentId = new Option("c", "content-id", true, "The id of the source content");
    contentId.setArgs(1);
    contentId.setArgName("contentId");
    options.addOption(contentId);

    Option contentIdFile = new Option("f", "content-id-file", true, "A file containing a list of content ids");
    contentIdFile.setArgs(1);
    contentIdFile.setArgName("content-id-file");
    options.addOption(contentIdFile);

    return options;
}

From source file:org.duracloud.mill.taskreadertool.Driver.java

private static Options getOptions() {
    Options options = new Options();

    Option queue = new Option("q", "queue", true, "A task queue name");
    queue.setArgs(1);
    queue.setArgName("queue");
    queue.setRequired(true);/* w  w w.  ja va  2 s  .  c om*/
    options.addOption(queue);

    Option username = new Option("u", "username", true, "The queue service username");
    username.setArgs(1);
    username.setArgName("username");
    queue.setRequired(true);
    options.addOption(username);

    Option password = new Option("p", "password", true, "The queue service password");
    password.setArgs(1);
    password.setArgName("password");
    queue.setRequired(true);
    options.addOption(password);

    Option output = new Option("o", "output-file-name", true, "The name of the output file");
    password.setArgs(1);
    password.setArgName("output");
    options.addOption(output);

    Option delete = new Option("d", "delete", false,
            "Indicates that items read from the queue should be deleted");
    options.addOption(delete);

    return options;
}

From source file:org.duracloud.mill.util.CommonCommandLineOptions.java

public CommonCommandLineOptions() {
    super();//from  w w w  .j a va 2 s. c  o m

    Option configFile = new Option(CONFIG_FILE_OPTION, "config-file", true,
            "A properties file containing configuration info");
    configFile.setArgs(1);
    configFile.setArgName("file");
    configFile.setRequired(true);
    addOption(configFile);
}

From source file:org.duracloud.retrieval.config.RetrievalToolConfigParser.java

/**
 * Creates a parser for command line configuration options.
 *///  w w  w  .j a  v  a  2  s.com
public RetrievalToolConfigParser() {
    cmdLineUtil = new CommandLineToolUtil();

    // Command Line Options
    cmdOptions = new Options();

    Option hostOption = new Option("h", "host", true,
            "the host address of the DuraCloud " + "DuraStore application");
    hostOption.setRequired(true);
    cmdOptions.addOption(hostOption);

    Option portOption = new Option("r", "port", true, "the port of the DuraCloud DuraStore application "
            + "(optional, default value is " + DEFAULT_PORT + ")");
    portOption.setRequired(false);
    cmdOptions.addOption(portOption);

    Option usernameOption = new Option("u", "username", true,
            "the username necessary to perform writes to DuraStore");
    usernameOption.setRequired(true);
    cmdOptions.addOption(usernameOption);

    Option passwordOption = new Option("p", "password", true,
            "the password necessary to perform writes to DuraStore; NOTICE: "
                    + "if no password is specified in the command line the retrieval tool will "
                    + "look for an environment variable named " + CommandLineToolUtil.PASSWORD_ENV_VARIABLE_NAME
                    + " containing the password.  Finally, if this environment variable "
                    + "does not exist the user will be prompted for the password.");
    passwordOption.setRequired(false);
    cmdOptions.addOption(passwordOption);

    Option storeIdOption = new Option("i", "store-id", true, "the Store ID for the DuraCloud storage provider");
    storeIdOption.setRequired(false);
    cmdOptions.addOption(storeIdOption);

    Option spaces = new Option("s", "spaces", true,
            "the space or spaces from which content will be " + "retrieved");
    spaces.setRequired(false);
    spaces.setArgs(Option.UNLIMITED_VALUES);
    cmdOptions.addOption(spaces);

    Option allSpaces = new Option("a", "all-spaces", false, "indicates that all spaces should be retrieved; if "
            + "this option is included the -s option is ignored " + "(optional, not set by default)");
    allSpaces.setRequired(false);
    cmdOptions.addOption(allSpaces);

    Option contentDirOption = new Option("c", "content-dir", true,
            "retrieved content is stored in this local directory");
    contentDirOption.setRequired(true);
    cmdOptions.addOption(contentDirOption);

    Option workDirOption = new Option("w", "work-dir", true,
            "logs and output files will be stored in the work "
                    + "directory (optional, set to duracloud-retrieval-work "
                    + "directory in user's home directory by default)");
    workDirOption.setRequired(false);
    cmdOptions.addOption(workDirOption);

    Option overwrite = new Option("o", "overwrite", false,
            "indicates that existing local files which differ "
                    + "from files in DuraCloud under the same path and name "
                    + "sould be overwritten rather than copied " + "(optional, not set by default)");
    overwrite.setRequired(false);
    cmdOptions.addOption(overwrite);

    Option numThreads = new Option("t", "threads", true, "the number of threads in the pool used to manage "
            + "file transfers (optional, default value is " + DEFAULT_NUM_THREADS + ")");
    numThreads.setRequired(false);
    cmdOptions.addOption(numThreads);

    Option disableTimestamps = new Option("d", "disable-timestamps", false,
            "indicates that timestamp information found as content "
                    + "item properties in DuraCloud should not be applied to "
                    + "local files as they are retrieved (optional, not set " + "by default)");
    disableTimestamps.setRequired(false);
    cmdOptions.addOption(disableTimestamps);

    Option listOnly = new Option("l", "list-only", false,
            "indicates that the retrieval tool should create a file "
                    + "listing the contents of the specified space rather than "
                    + "downloading the actual content files.  The list file "
                    + "will be placed in the specified content directory. "
                    + "One list file will be created for each specified space."
                    + "(optional, not set by default)");
    listOnly.setRequired(false);
    cmdOptions.addOption(listOnly);

    Option listFile = new Option("f", "list-file", true,
            "retrieve specific contents using content IDs in the "
                    + "specified file.  The specified file should contain "
                    + "one content ID per line.  This option can only " + "operate on one space at a time.");
    listFile.setRequired(false);
    cmdOptions.addOption(listFile);
}

From source file:org.duracloud.sync.config.SyncToolConfigParser.java

/**
 * Creates a parser for command line configuration options.
 *///from  w  w w  .  jav  a 2s  .co  m
public SyncToolConfigParser() {
    cmdLineUtil = new CommandLineToolUtil();

    // Command Line Options
    cmdOptions = new Options();

    Option hostOption = new Option("h", "host", true,
            "the host address of the DuraCloud " + "DuraStore application");
    hostOption.setRequired(true);
    cmdOptions.addOption(hostOption);

    Option portOption = new Option("r", "port", true, "the port of the DuraCloud DuraStore application "
            + "(optional, default value is " + DEFAULT_PORT + ")");
    portOption.setRequired(false);
    cmdOptions.addOption(portOption);

    Option usernameOption = new Option("u", "username", true,
            "the username necessary to perform writes to DuraStore");
    usernameOption.setRequired(true);
    cmdOptions.addOption(usernameOption);

    Option passwordOption = new Option("p", "password", true,
            "the password necessary to perform writes to DuraStore; NOTICE: "
                    + "if no password is specified in the command line the sync tool will "
                    + "look for an environment variable named " + CommandLineToolUtil.PASSWORD_ENV_VARIABLE_NAME
                    + " containing the password.  Finally, if this environment variable "
                    + "does not exist the user will be prompted for the password.");
    passwordOption.setRequired(false);
    cmdOptions.addOption(passwordOption);

    Option storeIdOption = new Option("i", "store-id", true, "the Store ID for the DuraCloud storage provider");
    storeIdOption.setRequired(false);
    cmdOptions.addOption(storeIdOption);

    Option spaceId = new Option("s", "space-id", true,
            "the ID of the DuraCloud space where content " + "will be stored");
    spaceId.setRequired(true);
    cmdOptions.addOption(spaceId);

    Option workDirOption = new Option("w", "work-dir", true, "the state of the sync tool is persisted to "
            + "this directory (optional, default value is " + "duracloud-sync-work directory in user home)");
    workDirOption.setRequired(false);
    cmdOptions.addOption(workDirOption);

    Option contentDirs = new Option("c", "content-dirs", true,
            "the directory paths to monitor and sync with DuraCloud");
    contentDirs.setRequired(true);
    contentDirs.setArgs(Option.UNLIMITED_VALUES);
    cmdOptions.addOption(contentDirs);

    Option pollFrequency = new Option("f", "poll-frequency", true,
            "the time (in ms) to wait between each poll of the " + "sync-dirs (optional, default value is "
                    + DEFAULT_POLL_FREQUENCY + ")");
    pollFrequency.setRequired(false);
    cmdOptions.addOption(pollFrequency);

    Option numThreads = new Option("t", "threads", true, "the number of threads in the pool used to manage "
            + "file transfers (optional, default value is " + DEFAULT_NUM_THREADS + ")");
    numThreads.setRequired(false);
    cmdOptions.addOption(numThreads);

    Option maxFileSize = new Option("m", "max-file-size", true,
            "the maximum size of a stored file in GB (value must "
                    + "be between 1 and 5), larger files will be split into "
                    + "pieces (optional, default value is " + DEFAULT_MAX_FILE_SIZE + ")");
    maxFileSize.setRequired(false);
    cmdOptions.addOption(maxFileSize);

    Option renameUpdates = new Option("n", "rename-updates", true,
            "indicates that updates should be synced to the cloud and renamed. "
                    + "Specify an optional suffix to override default " + "( \""
                    + SyncToolConfig.DEFAULT_UPDATE_SUFFIX + "\"); "
                    + "To prevent updates altogether, see option -o. " + "(optional, not set by default)");
    renameUpdates.setRequired(false);
    renameUpdates.setArgName("suffix");
    renameUpdates.setOptionalArg(true);
    cmdOptions.addOption(renameUpdates);

    Option syncUpdates = new Option("o", "no-update", false,
            "indicates that changed files should not be updated; "
                    + "to perform updates without overwriting, see option -n. "
                    + "(optional, not set by default)");
    syncUpdates.setRequired(false);
    cmdOptions.addOption(syncUpdates);

    Option syncDeletes = new Option("d", "sync-deletes", false,
            "indicates that deletes performed on files within the "
                    + "sync directories should also be performed on those "
                    + "files in DuraCloud; if this option is not included "
                    + "all deletes are ignored (optional, not set by default)");
    syncDeletes.setRequired(false);
    cmdOptions.addOption(syncDeletes);

    Option cleanStart = new Option("l", "clean-start", false,
            "indicates that the sync tool should perform a clean "
                    + "start, ensuring that all files in all content "
                    + "directories are checked against DuraCloud, even if "
                    + "those files have not changed locally since the last "
                    + "run of the sync tool. (optional, not set by default)");
    cleanStart.setRequired(false);
    cmdOptions.addOption(cleanStart);

    Option jumpStart = new Option("j", "jump-start", false,
            "indicates that the sync tool should not attempt to "
                    + "check if content to be synchronized is already in "
                    + "DuraCloud, but should instead transfer all content. "
                    + "This option is best used for new data sets. " + "(optional, not set by default)");
    jumpStart.setRequired(false);
    cmdOptions.addOption(jumpStart);

    Option exitOnCompletion = new Option("x", "exit-on-completion", false,
            "indicates that the sync tool should exit once it has "
                    + "completed a scan of the content directories and synced "
                    + "all files; if this option is included, the sync tool "
                    + "will not continue to monitor the sync dirs " + "(optional, not set by default)");
    exitOnCompletion.setRequired(false);
    cmdOptions.addOption(exitOnCompletion);

    Option excludeOption = new Option("e", "exclude", true, "file which provides a list of files and/or "
            + "directories to exclude from the sync (one file or " + "directory name rule per line)");
    excludeOption.setRequired(false);
    cmdOptions.addOption(excludeOption);

    Option prefixOption = new Option("a", "prefix", true,
            "a prefix that is added to the beginning of the ID of "
                    + "each content item that is stored in DuraCloud. For "
                    + "example, a prefix value of 'a/b/c/' with a content "
                    + "item whose path is 'dir1/file.txt' would result in "
                    + "the file stored in DuraCloud as 'a/b/c/dir1/file.txt " + "(optional)");
    prefixOption.setRequired(false);
    cmdOptions.addOption(prefixOption);

    // Options to use Backup Config
    configFileOptions = new Options();

    Option configFileOption = new Option("g", "config-file", true,
            "read configuration from this file (a file containing "
                    + "the most recently used configuration can be found in " + "the work-dir, named "
                    + BACKUP_FILE_NAME + ")");
    configFileOption.setRequired(true);
    configFileOptions.addOption(configFileOption);
}

From source file:org.duracloud.syncoptimize.config.SyncOptimizeConfigParser.java

/**
 * Creates a parser for command line configuration options.
 *//*from ww w. j  a v  a 2s. co m*/
public SyncOptimizeConfigParser() {
    cmdLineUtil = new CommandLineToolUtil();

    // Command Line Options
    cmdOptions = new Options();

    Option hostOption = new Option("h", "host", true,
            "the host address of the DuraCloud " + "DuraStore application");
    hostOption.setRequired(true);
    cmdOptions.addOption(hostOption);

    Option portOption = new Option("r", "port", true, "the port of the DuraCloud DuraStore application "
            + "(optional, default value is " + DEFAULT_PORT + ")");
    portOption.setRequired(false);
    cmdOptions.addOption(portOption);

    Option usernameOption = new Option("u", "username", true,
            "the username necessary to perform writes to DuraStore");
    usernameOption.setRequired(true);
    cmdOptions.addOption(usernameOption);

    Option passwordOption = new Option("p", "password", true,
            "the password necessary to perform writes to DuraStore; NOTICE: "
                    + "if no password is specified in the command line the retrieval tool will "
                    + "look for an environment variable named " + CommandLineToolUtil.PASSWORD_ENV_VARIABLE_NAME
                    + " containing the password.  Finally, if this environment variable "
                    + "does not exist the user will be prompted for the password.");
    passwordOption.setRequired(false);
    cmdOptions.addOption(passwordOption);

    Option spaceIdOption = new Option("s", "space", true, "the space in which test content will be placed");
    spaceIdOption.setRequired(true);
    spaceIdOption.setArgs(Option.UNLIMITED_VALUES);
    cmdOptions.addOption(spaceIdOption);

    Option numFilesOption = new Option("n", "num-files", true,
            "the number of files to transfer on each test run");
    numFilesOption.setRequired(false);
    cmdOptions.addOption(numFilesOption);

    Option sizeFilesOption = new Option("m", "size-files", true,
            "the size of files to transfer on each test run, in MB");
    sizeFilesOption.setRequired(false);
    cmdOptions.addOption(sizeFilesOption);

}

From source file:org.dvare.rest.api.App.java

public static void main(String[] args) throws Exception {

    Options options = new Options();

    Option option = new Option("port", true, "server port");
    option.setArgs(1);
    options.addOption(option);//  w  ww .  j  ava 2 s.c o  m

    options.addOption(option);

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);

    Server server = null;
    if (cmd.hasOption("port")) {
        String port = cmd.getOptionValue("port", "8080");
        if (port != null) {
            server = new Server(Integer.parseInt(port));
        }
    } else {

        String port = System.getProperty("server.port");
        if (port != null) {
            server = new Server(Integer.parseInt(port));
        } else {
            System.exit(1);
        }

    }
    ServletHolder servlet = new ServletHolder(new ServletContainer(new ApplicationConfig()));

    ServletContextHandler context = new ServletContextHandler(server, "/*");
    context.addServlet(servlet, "/api/*");

    HashSessionIdManager idmanager = new HashSessionIdManager();
    server.setSessionIdManager(idmanager);

    // Create the SessionHandler (wrapper) to handle the sessions
    HashSessionManager manager = new HashSessionManager();
    SessionHandler sessions = new SessionHandler(manager);
    context.setSessionHandler(sessions);

    try {
        server.start();
        server.join();
    } finally {
        server.destroy();
    }

}