@Override
  public void configure(Subparser subparser) {
    super.configure(subparser);

    subparser
        .addArgument("--" + OUT_OF_ORDER)
        .action(storeTrue())
        .setDefault(Boolean.FALSE)
        .dest(OUT_OF_ORDER)
        .help(
            "Allows migrations to be run \"out of order\". "
                + "If you already have versions 1 and 3 applied, and now a version 2 is found, it will be applied too instead of being ignored.");

    subparser
        .addArgument("--" + CLEAN_ON_VALIDATION_ERROR)
        .action(storeTrue())
        .setDefault(Boolean.FALSE)
        .dest(CLEAN_ON_VALIDATION_ERROR)
        .help(
            "Whether to automatically call clean or not when a validation error occurs. "
                + "This is exclusively intended as a convenience for development. "
                + "Even tough we strongly recommend not to change migration scripts once they have been checked into SCM and run, this provides a way of dealing with this case in a smooth manner. "
                + "The database will be wiped clean automatically, ensuring that the next migration will bring you back to the state checked into SCM. "
                + "Warning! Do not enable in production !");
  }
예제 #2
0
  public JobStopCommand(Subparser parser) {
    super(parser);

    parser.help("stop a running job without undeploying it");

    hostsArg = parser.addArgument("hosts").nargs("+").help("The hosts to stop the job on.");
  }
예제 #3
0
  public HostRegisterCommand(final Subparser parser) {
    super(parser);

    parser.help("register a host");

    hostArg = parser.addArgument("host");
    idArg = parser.addArgument("id");
  }
예제 #4
0
  @Override
  public void configureParser(Subparser parser) {
    parser.help(DESCRIPTION);
    parser.description(DESCRIPTION);

    Argument functionsArg = parser.addArgument(FUNCTIONS_ARG);
    functionsArg.dest(FUNCTIONS_ARG);
    functionsArg.metavar("<function>");
    functionsArg.nargs("*");
    functionsArg.help("function to invoke");
  }
예제 #5
0
파일: Cli.java 프로젝트: balooo/dropwizard
 private void addCommand(Command command) {
   commands.put(command.getName(), command);
   parser.addSubparsers().help("available commands");
   final Subparser subparser = parser.addSubparsers().addParser(command.getName(), false);
   command.configure(subparser);
   addHelp(subparser);
   subparser
       .description(command.getDescription())
       .setDefault(COMMAND_NAME_ATTR, command.getName())
       .defaultHelp(true);
 }
 @Override
 public void configure(Subparser subparser) {
   for (AbstractMongeezCommand<T> subcommand : subcommands.values()) {
     final Subparser cmdParser =
         subparser
             .addSubparsers()
             .addParser(subcommand.getName())
             .setDefault(COMMAND_NAME_ATTR, subcommand.getName())
             .description(subcommand.getDescription());
     subcommand.configure(cmdParser);
   }
 }
예제 #7
0
  @VisibleForTesting
  RollingUpdateCommand(
      final Subparser parser,
      final SleepFunction sleepFunction,
      final Supplier<Long> timeSupplier) {
    super(parser, true);

    this.sleepFunction = sleepFunction;
    this.timeSupplier = timeSupplier;

    parser.help("Initiate a rolling update");

    nameArg =
        parser.addArgument("deployment-group-name").required(true).help("Deployment group name");

    timeoutArg =
        parser
            .addArgument("-t", "--timeout")
            .setDefault(RolloutOptions.DEFAULT_TIMEOUT)
            .type(Long.class)
            .help("Fail rollout if a job takes longer than this to reach RUNNING (seconds)");

    parallelismArg =
        parser
            .addArgument("-p", "--par")
            .dest("parallelism")
            .setDefault(RolloutOptions.DEFAULT_PARALLELISM)
            .type(Integer.class)
            .help("Number of hosts to deploy to concurrently");

    asyncArg =
        parser
            .addArgument("--async")
            .action(storeTrue())
            .help("Don't block until rolling-update is complete");

    rolloutTimeoutArg =
        parser
            .addArgument("-T", "--rollout-timeout")
            .setDefault(60L)
            .type(Long.class)
            .help(
                "Exit if rolling-update takes longer than the given value (minutes). Note that "
                    + "this will NOT abort the rolling update, it will just cause this command to exit.");

    migrateArg =
        parser
            .addArgument("--migrate")
            .setDefault(false)
            .action(storeTrue())
            .help(
                "When specified a rolling-update will undeploy not only jobs previously deployed "
                    + "by the deployment-group but also jobs with the same job id. Use it ONCE when "
                    + "migrating a service to using deployment-groups");

    overlapArg =
        parser
            .addArgument("--overlap")
            .setDefault(false)
            .action(storeTrue())
            .help(
                "When specified a rolling-update will, for every host, first deploy the new "
                    + "version of a job before undeploying the old one. Note that the command will fail "
                    + "if the job contains static port assignments.");

    tokenArg =
        parser
            .addArgument("--token")
            .nargs("?")
            .setDefault(EMPTY_TOKEN)
            .help(
                "Insecure access token meant to prevent accidental changes to your job "
                    + "(e.g. undeploys).");
  }
예제 #8
0
 /**
  * Configure the command's {@link Subparser}.
  *
  * <p><strong> N.B.: if you override this method, you <em>must</em> call {@code
  * super.override(subparser)} in order to preserve the configuration file parameter in the
  * subparser. </strong>
  *
  * @param subparser the {@link Subparser} specific to the command
  */
 @Override
 public void configure(Subparser subparser) {
   subparser.addArgument("file").nargs("?").help("application configuration file");
 }
예제 #9
0
파일: Main.java 프로젝트: llinsbauer/ecco
  public static void main(String[] args) {

    EccoService eccoService = new EccoService();

    CLI cli = new CLI(eccoService);

    // # PICK APART ARGUMENTS ... #########################################
    // TODO: parse arguments

    ArgumentParser parser =
        ArgumentParsers.newArgumentParser("ecco").description("ECCO Description.");

    Subparsers subparsers =
        parser
            .addSubparsers()
            .title("subcommands")
            .description("valid subcommands")
            .help("additional help")
            .metavar("COMMAND")
            .dest("command");

    // initialize empty local repository
    Subparser parserInit = subparsers.addParser("init").help("init help");

    // status of local repository and working copy
    Subparser parserStatus = subparsers.addParser("status").help("status help");

    // get a configuration property <name>
    Subparser parserGet = subparsers.addParser("get").help("get help");
    parserGet.addArgument("name");

    // set a configuration property <name> to <value>
    Subparser parserSet = subparsers.addParser("set").help("set help");
    parserSet.addArgument("name");
    parserSet.addArgument("value");

    // checkout a configuration from the local repository as working copy (composition)
    Subparser parserCheckout = subparsers.addParser("checkout").help("checkout help");
    parserCheckout.addArgument("configurationString");

    // commit the working copy as a new configuration into the local repository
    Subparser parserCommit = subparsers.addParser("commit").help("commit help");
    parserCommit.addArgument("configurationString").required(false);

    // TODO: clone (cloning remote locally), fetch (fetching changes from remote), update (update
    // working copy), pull (fetch + update), push (push changes in local repository to remote), ...

    try {
      Namespace res = parser.parseArgs(args);
      System.out.println(res);

      switch (res.getString("command")) {
        case "init":
          cli.init();
          break;
        case "status":
          cli.status();
          break;
        case "get":
          cli.getProperty(res.getString("name"));
          break;
        case "set":
          cli.setProperty(res.getString("name"), res.getString("value"));
          break;
        case "checkout":
          cli.checkout(res.getString("configurationString"));
          break;
        case "commit":
          if (res.getString("configurationString") != null)
            cli.commit(res.getString("configurationString"));
          break;
      }

    } catch (HelpScreenException e) {
      parser.handleError(e);
    } catch (ArgumentParserException e) {
      System.err.println("ERROR: " + e.getMessage());
    } catch (EccoException e) {
      System.err.println("ERROR: " + e.getMessage());
    }
  }