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

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

Introduction

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

Prototype

int UNLIMITED_VALUES

To view the source code for org.apache.commons.cli Option UNLIMITED_VALUES.

Click Source Link

Document

constant that specifies the number of argument values is infinite

Usage

From source file:qpid.MulticastMain.java

private static Options getOptions() {
    Options options = new Options();
    options.addOption(new Option("?", "help", false, "show usage"));
    options.addOption(new Option("h", "uri", true, "AMQP URI"));
    options.addOption(new Option("t", "type", true, "exchange type"));
    options.addOption(new Option("e", "exchange", true, "exchange name"));
    options.addOption(new Option("u", "queue", true, "queue name"));
    options.addOption(new Option("i", "interval", true, "sampling interval"));
    options.addOption(new Option("r", "rate", true, "rate limit"));
    options.addOption(new Option("x", "producers", true, "producer count"));
    options.addOption(new Option("y", "consumers", true, "consumer count"));
    options.addOption(new Option("m", "ptxsize", true, "producer tx size"));
    options.addOption(new Option("n", "ctxsize", true, "consumer tx size"));
    options.addOption(new Option("c", "confirm", true, "max unconfirmed publishes"));
    options.addOption(new Option("a", "autoack", false, "auto ack"));
    options.addOption(new Option("A", "multiAckEvery", true, "multi ack every"));
    options.addOption(new Option("q", "qos", true, "qos prefetch count"));
    options.addOption(new Option("s", "size", true, "message size"));
    options.addOption(new Option("z", "time", true, "time limit"));
    Option flag = new Option("f", "flag", true, "message flag");
    flag.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(flag);//  www  .  j  av  a 2s .com
    options.addOption(new Option("M", "framemax", true, "frame max"));
    options.addOption(new Option("b", "heartbeat", true, "heartbeat interval"));
    return options;
}

From source file:runtime.starter.MPJAppMaster.java

public MPJAppMaster() {

    conf = new YarnConfiguration();
    opts = new Options();

    opts.addOption("np", true, "Number of Processes");
    opts.addOption("serverName", true, "Hostname required for Server Socket");
    opts.addOption("ioServerPort", true, "Port required for a socket" + " redirecting IO");
    opts.addOption("wireUpPort", true,
            "Port forwarded to Wrappers for " + "sharing read,write ports and ranks");
    opts.addOption("deviceName", true, "Specifies the MPJ device name");
    opts.addOption("className", true, "Main Class name");
    opts.addOption("wdir", true, "Specifies the current working directory");
    opts.addOption("psl", true, "Specifies the Protocol Switch Limit");
    opts.addOption("wrapperPath", true, "Specifies the wrapper jar path in hdfs");
    opts.addOption("userJarPath", true, "Specifies the user jar path in hdfs");
    opts.addOption("appArgs", true, "Specifies the User Application args");
    opts.getOption("appArgs").setArgs(Option.UNLIMITED_VALUES);
    opts.addOption("containerMem", true, "Specifies mpj containers memory");
    opts.addOption("containerCores", true, "Specifies mpj containers v-cores");
    opts.addOption("mpjContainerPriority", true,
            "Specifies the prioirty of" + "containers running MPI processes");
    opts.addOption("debugYarn", false, "Specifies the debug flag");

}

From source file:runtime.starter.MPJYarnClient.java

public MPJYarnClient() {
    logger = LogFactory.getLog(MPJYarnClient.class);
    conf = new YarnConfiguration();

    opts = new Options();

    opts.addOption("np", true, "Number of Processes");
    opts.addOption("server", true, "Hostname required for Server Socket");
    opts.addOption("serverPort", true, "Port required for Server Socket");
    opts.addOption("dev", true, "Specifies the MPJ device name");
    opts.addOption("className", true, "Main Class name");
    opts.addOption("wdir", true, "Specifies the current working directory");
    opts.addOption("psl", true, "Specifies the Protocol Switch Limit");
    opts.addOption("jarPath", true, "Specifies the Path to user's Jar File");
    opts.addOption("appArgs", true, "Specifies the User Application args");
    opts.getOption("appArgs").setArgs(Option.UNLIMITED_VALUES);
    opts.addOption("amMem", true, "Specifies AM container memory");
    opts.addOption("amCores", true, "Specifies AM container virtual cores");
    opts.addOption("containerMem", true, "Specifies mpj containers memory");
    opts.addOption("containerCores", true, "Specifies mpj containers v-cores");
    opts.addOption("yarnQueue", true, "Specifies the yarn queue");
    opts.addOption("appName", true, "Specifies the application name");
    opts.addOption("amPriority", true, "Specifies AM container priority");
    opts.addOption("mpjContainerPriority", true,
            "Specifies the prioirty of" + "containers running MPI processes");
    opts.addOption("hdfsFolder", true,
            "Specifies the HDFS folder where AM," + "Wrapper and user code jar files will be uploaded");
    opts.addOption("debugYarn", false, "Specifies the debug flag");
}

From source file:runtime.starter.MPJYarnWrapper.java

public MPJYarnWrapper() {
    opts = new Options();

    opts.addOption("serverName", true, "Hostname where the stdout and stderr " + "will be redirected");
    opts.addOption("ioServerPort", true, "Port required for a socket" + " redirecting IO");
    opts.addOption("deviceName", true, "Specifies the MPJ device name");
    opts.addOption("className", true, "Main Class name");
    opts.addOption("psl", true, "Protocol Switch Limit");
    opts.addOption("np", true, "Number of Processes");
    opts.addOption("rank", true, "Rank of the process, it is set by AM");
    opts.addOption("wireUpPort", true, "Port required by NIODev to share" + "wireup information");
    opts.addOption("appArgs", true, "Specifies the User Application args");
    opts.getOption("appArgs").setArgs(Option.UNLIMITED_VALUES);

}

From source file:scoutdoc.main.Main.java

/**
 * @param args/*w w  w.  jav a 2  s.c o m*/
 */
public static void main(String[] args) {
    Option optHelp = new Option(HELP_ID, "help", false, "print this message");

    Option optProp = new Option(PROP_ID, "config", true, "configuration file");
    optProp.setArgName("file");

    //source
    Option optTask = new Option(SOURCE_TASKS_ID, "task", true, "(source) one or many task files");
    optTask.setArgName("files");
    optTask.setArgs(Option.UNLIMITED_VALUES);

    Option optAllPages = new Option(SOURCE_ALL_PAGES_ID, "pages", false,
            "(source) use the pages contained in the source folder");

    Option optListPages = new Option(SOURCE_LIST_ID, "list", true,
            "(source) list of pages contained in the file");
    optListPages.setArgName("file");

    Option optRecentChange = new Option(SOURCE_RECENT_CHANGES_ID, "recent-changes", false,
            "(source) use the pages from the wiki recent changes");

    Option optRss = new Option(SOURCE_RSS_ID, "rss", false,
            "(source) use the pages from the rss feed of the wiki");

    OptionGroup sourceGroup = new OptionGroup();
    sourceGroup.setRequired(true);
    sourceGroup.addOption(optTask);
    sourceGroup.addOption(optAllPages);
    sourceGroup.addOption(optListPages);
    sourceGroup.addOption(optRecentChange);
    sourceGroup.addOption(optRss);

    Option optfilter = new Option(SOURCE_FILTER_ID, "filter", true, "Filter for list of pages used as source");
    optfilter.setArgName("class");

    List<String> values = Lists.newArrayList();
    for (Operation o : Operation.values()) {
        values.add(o.name());
    }
    Option optOperation = new Option(OPERATION_ID, "operation", true,
            "operation: " + Joiner.on(", ").join(values));
    optOperation.setArgName("operations");
    optOperation.setArgs(Option.UNLIMITED_VALUES);
    optOperation.setRequired(true);

    Option optOutputCheckstyle = new Option(OUTPUT_CHECKSTYLE_ID, "output-checkstyle", true,
            "(CHECK output) create a xml checkstyle file (<filename> is optional. Default: "
                    + DEFAULT_CHECKSTYLE_NAME + ")");
    optOutputCheckstyle.setArgName("filename");
    optOutputCheckstyle.setOptionalArg(true);

    Option optOutputDashboard = new Option(OUTPUT_DASHBOARD_ID, "output-dashboard", true,
            "(CHECK output) create an html dashboard (<folder> is optional. Default: " + DEFAULT_DASHBOARD_NAME
                    + ")");
    optOutputDashboard.setArgName("folder");
    optOutputDashboard.setOptionalArg(true);

    Options options = new Options();
    options.addOption(optHelp);
    options.addOption(optProp);
    options.addOptionGroup(sourceGroup);
    options.addOption(optfilter);
    options.addOption(optOperation);
    options.addOption(optOutputCheckstyle);
    options.addOption(optOutputDashboard);

    try {
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption(HELP_ID)) {
            printHelpAndExit(options);
        }

        if (cmd.hasOption(PROP_ID)) {
            ProjectProperties.initProperties(cmd.getOptionValue(PROP_ID));
        }
        Pages.initPageList();

        List<Operation> operations = readOptionEnum(cmd, optOperation, Operation.class);
        List<Task> tasks = readTasks(cmd, optTask);

        Collection<Page> pageList;
        if (cmd.hasOption(SOURCE_ALL_PAGES_ID)) {
            pageList = PageUtility.loadPages(ProjectProperties.getFolderWikiSource());
        } else if (cmd.hasOption(SOURCE_LIST_ID)) {
            String name = cmd.getOptionValue(SOURCE_LIST_ID);
            try {
                pageList = PageUtility.readList(name);
            } catch (IOException e) {
                throw new MissingArgumentException("IOException for file <" + name + "> for <"
                        + optListPages.getLongOpt() + "> : " + e.getMessage());
            }
        } else {
            pageList = Collections.emptyList();
        }

        IPageFilter filter;
        if (cmd.hasOption(SOURCE_FILTER_ID)) {
            if (tasks.size() > 0) {
                throw new MissingArgumentException("Filter <" + optfilter.getLongOpt()
                        + "> is not allowed for source <" + optTask.getLongOpt() + ">.");
            }
            filter = newInstance(cmd.getOptionValue(SOURCE_FILTER_ID), IPageFilter.class,
                    new AcceptAllPageFilter());
        } else {
            filter = new AcceptAllPageFilter();
        }
        List<Page> pages = Lists.newArrayList();
        for (Page page : pageList) {
            if (filter.keepPage(page)) {
                pages.add(page);
            }
        }

        if (operations.contains(Operation.FETCH)) {
            if (pages.size() > 0) {
                ScoutDocFetch sdf = new ScoutDocFetch();
                RelatedPagesStrategy strategy;
                if (cmd.hasOption(SOURCE_ALL_PAGES_ID)) {
                    strategy = RelatedPagesStrategy.NO_RELATED_PAGES;
                } else if (cmd.hasOption(SOURCE_LIST_ID)) {
                    strategy = RelatedPagesStrategy.IMAGES_TEMPLATES_AND_LINKS;
                } else {
                    throw new IllegalStateException("Page list comes from an unexpected option");
                }
                sdf.execute(pages, strategy);
            } else if (cmd.hasOption(SOURCE_RECENT_CHANGES_ID)) {
                ScoutDocFetch sdf = new ScoutDocFetch();
                sdf.executeRecentChanges(filter);
            } else if (cmd.hasOption(SOURCE_RSS_ID)) {
                ScoutDocFetch sdf = new ScoutDocFetch();
                sdf.executeRss(filter);
            } else if (tasks.size() > 0) {
                for (Task task : tasks) {
                    ScoutDocFetch sdf = new ScoutDocFetch();
                    sdf.execute(task);
                }
            } else {
                throw new MissingArgumentException("Missing a source");
            }
        }

        if (operations.contains(Operation.CHECK)) {
            ScoutDocCheck sdc = new ScoutDocCheck();
            List<Check> checks = Lists.newArrayList();
            ensureNotSet(cmd, optRecentChange, Operation.CHECK);
            ensureNotSet(cmd, optRss, Operation.CHECK);
            if (pages.size() > 0) {
                checks = sdc.analysePages(pages);
            } else if (tasks.size() > 0) {
                for (Task task : tasks) {
                    ScoutDocCheck sdcForTask = new ScoutDocCheck();
                    checks.addAll(sdcForTask.execute(task));
                }
            } else {
                throw new MissingArgumentException("Missing a source");
            }
            //output:
            if (cmd.hasOption(OUTPUT_CHECKSTYLE_ID)) {
                String fileName = cmd.getOptionValue(OUTPUT_CHECKSTYLE_ID, DEFAULT_CHECKSTYLE_NAME);
                sdc.writeCheckstyleFile(checks, fileName);
            }
            if (cmd.hasOption(OUTPUT_DASHBOARD_ID)) {
                String folderName = cmd.getOptionValue(OUTPUT_DASHBOARD_ID, DEFAULT_DASHBOARD_NAME);
                sdc.writeDashboardFiles(checks, folderName);
            }
        }

        if (operations.contains(Operation.CONVERT)) {
            ensureNotSet(cmd, optAllPages, Operation.CONVERT);
            ensureNotSet(cmd, optListPages, Operation.CONVERT);
            ensureNotSet(cmd, optRecentChange, Operation.CONVERT);
            ensureNotSet(cmd, optRss, Operation.CONVERT);
            if (tasks.size() > 0) {
                for (Task task : tasks) {
                    ScoutDocConverter sdc = new ScoutDocConverter();
                    sdc.execute(task);
                }
            } else {
                throw new MissingArgumentException("Missing a source");
            }
        }

    } catch (MissingOptionException e) {
        // Check if it is an error or if optHelp was selected.
        boolean help = false;
        try {
            Options helpOptions = new Options();
            helpOptions.addOption(optHelp);
            CommandLineParser parser = new PosixParser();
            CommandLine line = parser.parse(helpOptions, args);
            if (line.hasOption(HELP_ID)) {
                help = true;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        if (!help) {
            System.err.println(e.getMessage());
            System.err.flush();
        }
        printHelpAndExit(options);
    } catch (MissingArgumentException e) {
        System.err.println(e.getMessage());
        printHelpAndExit(options);
    } catch (ParseException e) {
        System.err.println("Error while parsing the command line: " + e.getMessage());
        System.exit(1);
    } catch (Exception e) {
        e.printStackTrace();
    }
}