Search in sources :

Example 56 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project toolkit by googleapis.

the class DiscoConfigGeneratorTool method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("h", "help", false, "show usage");
    options.addOption(Option.builder().longOpt(DISCOVERY_DOC_OPTION_NAME).desc("The filepath of the raw Discovery document.").hasArg().argName("DISCOVERY-FILE").required(true).build());
    options.addOption(Option.builder("o").longOpt("output").desc("The directory in which to output the generated config.").hasArg().argName("OUTPUT-FILE").required(true).build());
    CommandLine cl = (new DefaultParser()).parse(options, args);
    if (cl.hasOption("help")) {
        HelpFormatter formater = new HelpFormatter();
        formater.printHelp("ConfigGeneratorTool", options);
    }
    generate(cl.getOptionValue(DISCOVERY_DOC_OPTION_NAME), cl.getOptionValue("output"));
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) ToolOptions(com.google.api.tools.framework.tools.ToolOptions) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 57 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project toolkit by googleapis.

the class SynchronizerTool method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("h", "help", false, "show usage");
    options.addOption(Option.builder().longOpt("source_path").desc("The directory which contains the final code.").hasArg().argName("SOURCE-PATH").required(true).build());
    options.addOption(Option.builder().longOpt("generated_path").desc("The directory which contains the generated code.").hasArg().argName("GENERATED-PATH").build());
    options.addOption(Option.builder().longOpt("baseline_path").desc("The directory which contains the baseline code.").hasArg().argName("BASELINE-PATH").build());
    options.addOption(Option.builder().longOpt("auto_merge").desc("If set, no GUI will be launched if merge can be completed automatically.").argName("AUTO-MERGE").build());
    options.addOption(Option.builder().longOpt("auto_resolve").desc("Whether to enable smart conflict resolution").argName("AUTO_RESOLVE").build());
    options.addOption(Option.builder().longOpt("ignore_base").desc("If true, the baseline will be ignored and two-way merge will be used.").argName("IGNORE_BASE").build());
    CommandLine cl = (new DefaultParser()).parse(options, args);
    if (cl.hasOption("help")) {
        HelpFormatter formater = new HelpFormatter();
        formater.printHelp("CodeGeneratorTool", options);
    }
    synchronize(cl.getOptionValue("source_path"), cl.getOptionValue("generated_path"), cl.getOptionValue("baseline_path"), cl.hasOption("auto_merge"), cl.hasOption("auto_resolve"), cl.hasOption("ignore_base"));
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) ToolOptions(com.google.api.tools.framework.tools.ToolOptions) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 58 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project grakn by graknlabs.

the class MigrationOptions method parse.

protected void parse(String[] args) {
    try {
        CommandLineParser parser = new DefaultParser();
        command = parser.parse(options, args);
        numberOptions = command.getOptions().length;
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 59 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project grakn by graknlabs.

the class GraqlShellOptions method create.

public static GraqlShellOptions create(String[] args, Options additionalOptions) throws ParseException {
    Options options = defaultOptions();
    for (Option option : additionalOptions.getOptions()) {
        options.addOption(option);
    }
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);
    return new GraqlShellOptions(options, cmd);
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 60 with DefaultParser

use of org.apache.commons.cli.DefaultParser in project scheduling by ow2-proactive.

the class RMNodeUpdater method parseCommandLine.

@Override
protected String parseCommandLine(String[] args) {
    final Options options = new Options();
    fillOptions(options);
    final CommandLineParser parser = new DefaultParser();
    CommandLine cl;
    try {
        cl = parser.parse(options, args);
        // now we update this object's fields given the options.
        String nodeName = fillParameters(cl, options);
        // check the user supplied values
        // performed after fillParameters to be able to override fillParameters in subclasses
        checkUserSuppliedParameters();
        return nodeName;
    } catch (ParseException pe) {
        logger.error("Error when parsing arguments", pe);
        System.exit(ExitStatus.RMNODE_PARSE_ERROR.exitCode);
    }
    return null;
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

DefaultParser (org.apache.commons.cli.DefaultParser)65 CommandLine (org.apache.commons.cli.CommandLine)63 Options (org.apache.commons.cli.Options)49 CommandLineParser (org.apache.commons.cli.CommandLineParser)45 ParseException (org.apache.commons.cli.ParseException)43 HelpFormatter (org.apache.commons.cli.HelpFormatter)30 Option (org.apache.commons.cli.Option)20 IOException (java.io.IOException)8 ToolOptions (com.google.api.tools.framework.tools.ToolOptions)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 File (java.io.File)5 Config (com.twitter.heron.spi.common.Config)3 PrintStream (java.io.PrintStream)3 Topology (com.ibm.streamsx.topology.Topology)2 PackingException (com.twitter.heron.spi.packing.PackingException)2 FileNotFoundException (java.io.FileNotFoundException)2 PrintWriter (java.io.PrintWriter)2 Path (java.nio.file.Path)2 Properties (java.util.Properties)2