Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineParser


  public void realMain(String[] args) throws Exception {
    Map clusterConf = Utils.readStormConfig();
    clusterConf.putAll(Utils.readCommandLineOpts());
    Nimbus.Client client = NimbusClient.getConfiguredClient(clusterConf).getClient();

    CmdLineParser parser = new CmdLineParser(this);
    parser.setUsageWidth(80);
    try {
      // parse the arguments.
      parser.parseArgument(args);
    } catch( CmdLineException e ) {
      // if there's a problem in the command line,
      // you'll get this exception. this will report
      // an error message.
      System.err.println(e.getMessage());
      _help = true;
    }
    if(_help) {
      parser.printUsage(System.err);
      System.err.println();
      return;
    }
    if (_numWorkers <= 0) {
      throw new IllegalArgumentException("Need at least one worker");
View Full Code Here


    public abstract void solve();

    public abstract void prettyOut();

    public final boolean readArgs(String... args) {
        CmdLineParser parser = new CmdLineParser(this);
        parser.setUsageWidth(160);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            System.err.println("java " + this.getClass() + " [options...]");
            parser.printUsage(System.err);
            System.err.println();
            return false;
        }
        return true;
    }
View Full Code Here

        run();
    }


    public final void readArgs(String... args) {
        CmdLineParser parser = new CmdLineParser(this);
        parser.setUsageWidth(160);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            System.err.println("java " + this.getClass() + " [options...]");
            parser.printUsage(System.err);
            System.err.println();
            System.exit(-1);
        }
    }
View Full Code Here

  @Option(name = "--dry_run",
      usage = "Use this to display what changes would be made without applying the changes.")
  private boolean dryRun = false;

  private void doMain(String[] args) throws Exception {
    CmdLineParser parser = new CmdLineParser(this);
    parser.parseArgument(args);
    if (displayHelp) {
      CmdLineParser p = new CmdLineParser(this);
      p.printUsage(System.out);
      return;
    }
    Preconditions.checkArgument(
        !inputs.isEmpty(), "At least one input must be provided in the --inputs flag.");
    Preconditions.checkArgument(
View Full Code Here

    return setUpCode;
  }

  public static void main(String[] args) throws Exception {
    Driver driver = new Driver();
    CmdLineParser parser = new CmdLineParser(driver);
    try {
      parser.parseArgument(args);
    } catch (CmdLineException e) {
      // handling of wrong arguments
      System.err.println(e.getMessage());
      parser.printUsage(System.err);
      System.exit(1);
    }
    driver.run();
    System.exit(0);
  }
View Full Code Here

    /**
     * Parse the given args list.
     */
    private void parse(List<String> args) throws CmdLineException {
      CmdLineParser parser = new CmdLineParser(this);
      parser.parseArgument(args.toArray(new String[] {}));

      compilationLevelParsed =
          COMPILATION_LEVEL_MAP.get(compilationLevel.toUpperCase());
      if (compilationLevelParsed == null) {
        throw new CmdLineException(
View Full Code Here

      }

    }

    private void printUsage(PrintStream ps) {
      CmdLineParser p = new CmdLineParser(this);
      p.printUsage(new OutputStreamWriter(ps), null, OptionHandlerFilter.ALL);
      ps.flush();
    }
View Full Code Here

      ps.flush();
    }

    private void printShortUsageAfterErrors(PrintStream ps) {
      ps.print("Sample usage: ");
      ps.println((new CmdLineParser(this)).printExample(OptionHandlerFilter.PUBLIC, null));
      ps.println("Run with --help for all options and details");
      ps.flush();
    }
View Full Code Here

          matchPaths(pattern, allJsInputs);
        }
      }

      if (!patterns.isEmpty() && allJsInputs.isEmpty()) {
        throw new CmdLineException(new CmdLineParser(this), "No inputs matched");
      }

      return new ArrayList<>(allJsInputs);
    }
View Full Code Here

  public static void main(final String[] args) {
    /*
     * Start and parse the arguments
     */
    final StartConsole bean = new StartConsole();
    final CmdLineParser parser = new CmdLineParser(bean);
    try {
      parser.parseArgument(args);
      if (bean.showHelp) {
        parser.printUsage(System.out);
      } else {
        bean.run();
      }
      System.out.println("Ending program.");
    } catch (final CmdLineException e) {
      /* handling of wrong arguments */
      System.err.println(e.getMessage());
      parser.printUsage(System.err);
    }
    System.exit(0);
  }
 
View Full Code Here

TOP

Related Classes of org.kohsuke.args4j.CmdLineParser

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.