Package org.apache.commons.cli

Examples of org.apache.commons.cli.CommandLineParser


    private static final int BUF_SIZE = 8192;


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

        CommandLineParser parser = new PosixParser();

        // create the Options
        Options options = new Options();
        options.addOption(option("v", "version", "cmd.deploy.opt.version"));
        options.addOption(option("h", "help", "cmd.deploy.opt.help"));
        options.addOption(option("o", "offline", "cmd.deploy.opt.offline"));
        options.addOption(option("s", "server-url", "url", "cmd.deploy.opt.server"));
        options.addOption(option("d", "debug", "cmd.deploy.opt.debug"));
        options.addOption(option("q", "quiet", "cmd.deploy.opt.quiet"));
        options.addOption(option("u", "undeploy", "cmd.deploy.opt.undeploy"));
        options.addOption(option(null, "dir", "cmd.deploy.opt.dir"));

        CommandLine line;
        try {
            // parse the command line arguments
            line = parser.parse(options, args);
        } catch (ParseException exp) {
            help(options);
            throw new SystemExitException(-1);
        }
View Full Code Here


  }

  public static CommandLine processCommandLineArgs(String[] cliArgs)
      throws Exception
  {
    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

public class Main {

    private static Messages messages = new Messages(Main.class);

    public static void main(String args[]) throws SystemExitException {
        CommandLineParser parser = new PosixParser();

        // create the Options
        Options options = new Options();
        options.addOption(option("v", "version", "cmd.start.opt.version"));
        options.addOption(option("h", "help", "cmd.start.opt.help"));
        options.addOption(option(null, "conf", "file", "cmd.start.opt.conf"));
        options.addOption(option(null, "local-copy", "boolean", "cmd.start.opt.localCopy"));
        options.addOption(option(null, "examples", "cmd.start.opt.examples"));

        ResourceFinder finder = new ResourceFinder("META-INF/");

        Set<String> services = null;
        try {
            Map<String, Properties> serviceEntries = finder.mapAvailableProperties(ServerService.class.getName());
            services = serviceEntries.keySet();
            for (String service : services) {
                options.addOption(option(null, service+"-port", "int", "cmd.start.opt.port", service));
                options.addOption(option(null, service+"-bind", "host", "cmd.start.opt.bind", service));
            }
        } catch (IOException e) {
            services = Collections.EMPTY_SET;
        }

        CommandLine line = null;
        try {
            // parse the command line arguments
            line = parser.parse(options, args);
        } catch (ParseException exp) {
            help(options);
            throw new SystemExitException(-1);
        }
View Full Code Here

                            cliOptions);
  }

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

    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

    private static final String defaultServerUrl = "ejbd://localhost:4201";

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

        CommandLineParser parser = new PosixParser();

        // create the Options
        Options options = new Options();
        options.addOption(Undeploy.option("v", "version", "cmd.deploy.opt.version"));
        options.addOption(Undeploy.option("h", "help", "cmd.undeploy.opt.help")); // TODO this message doesn't exist
        options.addOption(Undeploy.option("s", "server-url", "url", "cmd.deploy.opt.server"));

        CommandLine line = null;
        try {
            // parse the command line arguments
            line = parser.parse(options, args);
        } catch (ParseException exp) {
            Undeploy.help(options);
            throw new SystemExitException(-1);
        }
View Full Code Here

    public MyOptions(String[] args) {
      seed = System.nanoTime();

      try {
        Options opts = buildOptions();
        CommandLineParser parser = new GnuParser();
        CommandLine line = parser.parse(opts, args, true);
        processOptions(line, opts);
        validateOptions();
      }
      catch (ParseException e) {
        System.out.println(e.getMessage());
View Full Code Here

        finder = new ResourceFinder(BASE_PATH);
        locale = Locale.getDefault().getLanguage();
        descriptionI18n = descriptionBase + "." + locale;


        CommandLineParser parser = new PosixParser();

        // create the Options
        Options options = new Options();
        options.addOption(null, "version", false, "");
        options.addOption("h", "help", false, "");
        options.addOption("e", "errors", false, "Produce execution error messages");

        CommandLine line = null;
        String commandName = null;
        try {
            // parse the arguments up until the first
            // command, then let the rest fall into
            // the arguments array.
            line = parser.parse(options, args, true);

            // Get and remove the commandName (first arg)
            List<String> list = line.getArgList();
            if (list.size() > 0){
                commandName = list.get(0);
View Full Code Here

    public MyOptions(String[] args) {
      seed = System.nanoTime();

      try {
        Options opts = buildOptions();
        CommandLineParser parser = new GnuParser();
        CommandLine line = parser.parse(opts, args, true);
        processOptions(line, opts);
        validateOptions();
      }
      catch (ParseException e) {
        System.out.println(e.getMessage());
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

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

        long startTimeMillis = System.currentTimeMillis();

        Main.setOptions();
        CommandLineParser parser = new PosixParser();
        CommandLine line = parser.parse( options, args );

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        }
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.