Package org.apache.commons.cli

Examples of org.apache.commons.cli.Option$Builder


  /**
   * @param _commandNames
   */
  public Alias() {
    super("alias");
    getOptions().addOption(new Option("d", "delete", false, "delete the specified alias"));
  }
View Full Code Here


  }
 
  protected Options getOptions()
  {
    Options options = new Options();
    options.addOption( new Option("f", "filename", true, "filename to write log to"));
    return options;
  }
View Full Code Here

  {

    public AddUserCommand()
    {
      super("add", "a");
      getOptions().addOption(new Option("u", "username", true, "name of new user"));
      getOptions().addOption(new Option("p", "password", true, "password for new user"));
      getOptions().addOption(new Option("t", "type", true, "user type (Admin / User / Guest)"));
      getOptions().addOption(new Option("d", "savedirectory", true, "default torrent save directory for this user"));
    }
View Full Code Here

  {

    public DeleteUserCommand()
    {
      super("delete", "d");
      getOptions().addOption(new Option("u", "username", true, "name of user to delete"));
    }
View Full Code Here

    public ModifyUserCommand()
    {
      super("modify", "m");
     
      getOptions().addOption(new Option("u", "username", true, "name of user to modify"));
      getOptions().addOption(new Option("p", "password", true, "password for new user"));
      getOptions().addOption(new Option("t", "type", true, "user type (Admin / User / Guest)"));
      getOptions().addOption(new Option("d", "savedirectory", true, "default torrent save directory for this user"));

    }
View Full Code Here

  public static void main(String[] args) {
    // Parse command line options
    Options options = new Options();

    Option helpOption = new Option("h", "help", false, "print this help");
    Option serverURLOption = new Option("s", "serverURL", true,
        "URL of Sesame server to connect to, e.g. http://localhost/openrdf-sesame/ (required)");
    Option keyOption = new Option("k", "shutdownKey", true, "Key to shut down server");

    options.addOption(helpOption);
    options.addOption(serverURLOption);
    options.addOption(keyOption);

    CommandLineParser argsParser = new PosixParser();

    try {
      CommandLine commandLine = argsParser.parse(options, args);

      if (commandLine.hasOption(helpOption.getOpt())) {
        printUsage(options);
        System.exit(0);
      }

      String serverURL = commandLine.getOptionValue(serverURLOption.getOpt());
      String[] otherArgs = commandLine.getArgs();

      if (serverURL == null || otherArgs.length > 1) {
        System.out.println("Please specify a server URL");
        printUsage(options);
        System.exit(2);
      }

      if (!serverURL.endsWith("/")) {
        serverURL += "/";
      }
      serverURL += SesameServer.SHUTDOWN_PATH;

      String keyString = commandLine.getOptionValue(keyOption.getOpt());

      try {
        URL url = new URL(serverURL);

        System.out.println("connecting to the server...");
View Full Code Here

    Console console = new Console();

    // Parse command line options
    Options options = new Options();

    Option helpOption = new Option("h", "help", false, "print this help");
    Option versionOption = new Option("v", "version", false, "print version information");
    Option serverURLOption = new Option("s", "serverURL", true,
        "URL of Sesame server to connect to, e.g. http://localhost/openrdf-sesame/");
    Option dirOption = new Option("d", "dataDir", true, "Sesame data dir to 'connect' to");

    options.addOption(helpOption);
    options.addOption(versionOption);

    OptionGroup connectGroup = new OptionGroup();
    connectGroup.addOption(serverURLOption);
    connectGroup.addOption(dirOption);
    options.addOptionGroup(connectGroup);

    CommandLineParser argsParser = new PosixParser();

    try {
      CommandLine commandLine = argsParser.parse(options, args);

      if (commandLine.hasOption(helpOption.getOpt())) {
        printUsage(options);
        System.exit(0);
      }

      if (commandLine.hasOption(versionOption.getOpt())) {
        System.out.println(VERSION);
        System.exit(0);
      }

      String dir = commandLine.getOptionValue(dirOption.getOpt());
      String serverURL = commandLine.getOptionValue(serverURLOption.getOpt());
      String[] otherArgs = commandLine.getArgs();

      if (otherArgs.length > 1) {
        printUsage(options);
View Full Code Here

  /**
   * Create the <TT>Options</TT> object used to parse the command line.
   */
  private void createOptions()
  {
    Option opt;

    opt = createAnOption(IOptions.NO_SPLASH);
    _options.addOption(opt);

    opt = createAnOption(IOptions.HELP);
View Full Code Here

    _options.addOption(opt);
  }

  private Option createAnOption(String[] argInfo)
  {
    Option opt = new Option(argInfo[0], argInfo[2]);
    if (!isStringEmpty(argInfo[1]))
    {
      opt.setLongOpt(argInfo[1]);
    }

    return opt;
  }
View Full Code Here

  private Option createAnOptionWithArgument(String[] argInfo)
  {
    OptionBuilder.withArgName(argInfo[0]);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(argInfo[2]);
    Option opt = OptionBuilder.create( argInfo[0]);
    if (!isStringEmpty(argInfo[1]))
    {
      opt.setLongOpt(argInfo[1]);
    }
    return opt;
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.Option$Builder

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.