Java Code Examples for net.sourceforge.argparse4j.inf.ArgumentParser#addArgumentGroup()

The following examples show how to use net.sourceforge.argparse4j.inf.ArgumentParser#addArgumentGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CliMain.java    From styx with Apache License 2.0 6 votes vote down vote up
private GlobalOptions(ArgumentParser parser, CliContext cliContext, boolean subCommand) {
  this.options = parser.addArgumentGroup("global options");
  this.host = options.addArgument("-H", "--host")
      .help("Styx API host (can also be set with environment variable " + ENV_VAR_PREFIX + "_HOST)")
      .setDefault(subCommand ? FeatureControl.SUPPRESS : null)
      .setDefault(cliContext.env().get(ENV_VAR_PREFIX + "_HOST"))
      .action(Arguments.store());
  this.json = options.addArgument("--json")
      .help("json output")
      .setDefault(subCommand ? FeatureControl.SUPPRESS : null)
      .action(Arguments.storeTrue());
  this.plain = options.addArgument("-p", "--plain")
      .help("plain output")
      .setDefault(subCommand ? FeatureControl.SUPPRESS : null)
      .action(Arguments.storeTrue());
  this.debug = options.addArgument("--debug")
      .help("debug output")
      .setDefault(subCommand ? FeatureControl.SUPPRESS : null)
      .action(Arguments.storeTrue());
}
 
Example 2
Source File: RefreshSchema.java    From emodb with Apache License 2.0 4 votes vote down vote up
@Override
protected void addArguments(ArgumentParser parser) {
    ArgumentGroup schemaGroup = parser.addArgumentGroup("schemas");
    schemaGroup.description("Schemas generated by this script");

    schemaGroup.addArgument("--emoSchema")
            .dest("emoSchema")
            .metavar("NAME")
            .nargs("?")
            .help("Name of the schema where \"emodb\" located tables are generated");

    schemaGroup.addArgument("--stashSchema")
            .dest("stashSchema")
            .metavar("NAME")
            .nargs("?")
            .help("Name of the schema where \"emostash\" located tables are generated");

    parser.addArgument("--location")
            .dest("location")
            .metavar("EMOURL")
            .nargs("?")
            .required(true)
            .help("URI location of the EmoDB server, such as \"emodb://ci.us\"");

    parser.addArgument("--apiKey")
            .dest("apiKey")
            .metavar("KEY")
            .nargs("?")
            .required(true)
            .help("API key for connecting to EmoDB");

    parser.addArgument("--compatibility")
            .dest("compatibility")
            .nargs("?")
            .choices("hive", "general")
            .setDefault("hive")
            .help("hive = Use custom SerDe and InputFormat to provide efficiency and rich column names (default).  " +
                    "general = No custom SerDe or InputFormat so is more compatible with Hive alternatives like " +
                    "Presto and Impala but is slightly less efficient and only provides a single JSON column.");

    parser.addArgument("--disableIfNotExists")
            .dest("disableIfNotExists")
            .action(storeTrue())
            .setDefault(false)
            .help("Disables \"IF NOT EXISTS\" from being included in each \"CREATE TABLE\" command");

    parser.addArgument("--recreateTables")
            .dest("recreateTables")
            .action(storeTrue())
            .setDefault(false)
            .help("Drops each table if it exists prior to the \"CREATE TABLE\" command");
}
 
Example 3
Source File: CliParser.java    From helios with Apache License 2.0 4 votes vote down vote up
GlobalArgs(final ArgumentParser parser, final CliConfig cliConfig, final boolean topLevel) {
  this.globalArgs = parser.addArgumentGroup("global options");
  this.topLevel = topLevel;

  masterArg = addArgument("-z", "--master")
      .action(append())
      .help("master endpoints");

  domainsArg = addArgument("-d", "--domains")
      .setDefault(new ArrayList<>())
      .action(append())
      .help("domains");

  srvNameArg = addArgument("--srv-name")
      .setDefault(cliConfig.getSrvName())
      .help("master srv name");

  usernameArg = addArgument("-u", "--username")
      .setDefault(System.getProperty("user.name"))
      .help("username");

  googleCredentialsArg = addArgument("--google-credentials")
      .type(Boolean.class)
      .setDefault(true)
      .help("enable authentication using access tokens derived from Google Credentials");

  verbose = addArgument("-v", "--verbose")
      .action(Arguments.count());

  addArgument("--version")
      .action(Arguments.version())
      .help("print version");

  jsonArg = addArgument("--json")
      .action(storeTrue())
      .help("json output");

  noLogSetup = addArgument("--no-log-setup")
      .action(storeTrue())
      .help(SUPPRESS);

  // note: because of the way the HeliosClient is constructed, these next arguments are
  // read indirectly in cli/Utils.java:

  addArgument("-k", "--insecure")
      .action(storeTrue())
      .help("Disables hostname verification of HTTPS connections. "
            + "Similar to 'curl -k'. "
            + "Useful when using -z flag to connect directly to a master using HTTPS which "
            + "presents a certificate whose subject does not match the actual hostname.");

  // for http-timeout and retry-timeout, do not set a default value in the argument, so that
  // envrionment variables can be inspected in the Utils client factory.
  addArgument("--http-timeout")
      .type(Integer.class)
      .help("Timeout (in seconds) for each HTTP/S request to the master. "
            + "If this flag is not set, the value in the environment variable "
            + Utils.HTTP_TIMEOUT_ENV_VAR + " will be used. "
            + "If this environment variable is not set, then the default is "
            + Utils.DEFAULT_HTTP_TIMEOUT_SECS + " seconds.");

  addArgument("--retry-timeout")
      .type(Integer.class)
      .help("Total timeout (in seconds) for all of the requests that helios makes to the "
            + "master. If an individual request fails, helios will retry the request again "
            + "until successful or until this timeout elapses. "
            + "If this flag is not set, the value in the environment variable "
            + Utils.TOTAL_TIMEOUT_ENV_VAR + " will be used. "
            + "If this environment variable is not set, then the default is "
            + Utils.DEFAULT_TOTAL_TIMEOUT_SECS + " seconds.");
}