Package org.apache.commons.cli

Examples of org.apache.commons.cli.CommandLineParser


        }
    }

    static Configuration configure(String[] args) throws ParseException {
        assert args != null;
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(OPTIONS, args);
        String output = cmd.getOptionValue(OPT_OUTPUT.getOpt());
        String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt());
        Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt()));
        Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt()));
        String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt());
View Full Code Here


        assert args != null;
        if (LOG.isDebugEnabled()) {
            LOG.debug("Parsing options: {}", Arrays.toString(args));
        }

        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(OPTIONS, args);

        boolean recursive = cmd.hasOption(OPT_RECURSIVE.getOpt());
        String keepString = cmd.getOptionValue(OPT_KEEP_DAYS.getOpt());
        boolean dryRun = cmd.hasOption(OPT_DRY_RUN.getOpt());
        String[] rest = cmd.getArgs();
View Full Code Here

     * @return 復元した設定情報
     * @throws IllegalStateException 復元に失敗した場合
     */
    public static Configuration loadConfigurationFromArguments(String[] args) {
        assert args != null;
        CommandLineParser parser = new BasicParser();
        CommandLine cmd;
        try {
            cmd = parser.parse(OPTIONS, args);
        } catch (ParseException e) {
            throw new IllegalStateException(e);
        }

        Configuration result = new Configuration();
View Full Code Here

import org.apache.hadoop.util.ToolRunner;

public class JRubyJobRunner extends Configured implements Tool {

  public int run(String[] args) throws Exception {
    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption(new Option("script", true, "ruby script"));
    options
        .addOption(new Option("dslfile", true, "hadoop ruby DSL script"));

    CommandLine commandLine = parser.parse(options, args);
    JobConf conf = new JobConf(getConf(), JRubyJobRunner.class);
    conf.setJobName("ruby.runner");

    if (commandLine.hasOption("script")) {
      conf.set("mapred.ruby.script", commandLine.getOptionValue("script",
View Full Code Here

    // process command line

    Options options = new Options();
    options.addOption("p", "port", true, "service port");
    options.addOption("m", "multiuser", false, "enable multiuser mode");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
    int port = 8080;
    if (cmd.hasOption("p")) {
      port = Integer.valueOf(cmd.getOptionValue("p"));
    }
View Full Code Here

    public boolean shouldPrintHelp() {
      return shouldPrintHelp;
    }
   
    public void parse(String ... argv) throws ParseException {
      CommandLineParser parser = new PosixParser();
      CommandLine cmdLine = parser.parse(options, argv);
     
      if (cmdLine.hasOption(helpOpt.getOpt())
          || cmdLine.hasOption(helpOpt.getLongOpt())) {
        shouldPrintHelp = true;
        return;
View Full Code Here

        throws ParseException
    {
        // We need to eat any quotes surrounding arguments...
        String[] cleanArgs = cleanArgs( args );

        CommandLineParser parser = new GnuParser();
        return parser.parse( options, cleanArgs );
    }
View Full Code Here

     * @param args arguments passed on the command line
     * @throws ParseException for missing required, or unrecognized options
     */
    private void parseArgs(String[] args) throws ParseException
    {
        CommandLineParser parser = new PosixParser();
        cmd = parser.parse(options, args);
    }
View Full Code Here

    {
      HelpFormatter helpFormatter = new HelpFormatter();
      helpFormatter.printHelp("java " + ZKDumper.class.getName(), options);
      System.exit(1);
    }
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
    cmd.hasOption("zkSvr");
    boolean download = cmd.hasOption("download");
    boolean upload = cmd.hasOption("upload");
    boolean del = cmd.hasOption("delete");
    String zkAddress = cmd.getOptionValue("zkSvr");
View Full Code Here

    helpFormatter.printHelp("java " + ClusterSetup.class.getName(), cliOptions);
  }

  public static CommandLine processCommandLineArgs(String[] cliArgs)
  {
    CommandLineParser cliParser = new GnuParser();
    Options cliOptions = constructCommandLineOptions();
    // CommandLine cmd = null;

    try
    {
      return cliParser.parse(cliOptions, cliArgs);
    }
    catch (ParseException pe)
    {
      System.err.println("CommandLineClient: failed to parse command-line options: "
          + pe.toString());
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.CommandLineParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.