ManageUsersCommand extends AbstractStroomAccountConfiguredCommand { private String asArg(final String name) { return "--" + name; } ManageUsersCommand(final Path configFile); @Override void configure(final Subparser subparser);  }
@Test void test() throws ArgumentParserException { ArgumentParser parser = ArgumentParsers.newFor("test").build() .description("My test"); final Subparsers subparsers = parser.addSubparsers(); final Subparser subparser = subparsers.addParser("manageUsers"); subparser.addArgument(asArg(CREATE_USER_ARG_NAME)) .dest(CREATE_USER_ARG_NAME) .action(Arguments.append()) .type(String.class) .nargs(1) .metavar(USER_META_VAR) .help("The id of the user to create"); subparser.addArgument(asArg(CREATE_GROUP_ARG_NAME)) .dest(CREATE_GROUP_ARG_NAME) .action(Arguments.append()) .type(String.class) .nargs(1) .metavar(GROUP_META_VAR) .help("The id of the group to create"); subparser.addArgument(asArg(ADD_TO_GROUP_ARG_NAME)) .dest(ADD_TO_GROUP_ARG_NAME) .action(Arguments.append()) .type(String.class) .nargs(2) .required(false) .metavar(USER_OR_GROUP_META_VAR, TARGET_GROUP_META_VAR) .help("The name of the user/group being added and the group to add it to"); subparser.addArgument(asArg(REMOVE_FROM_GROUP_ARG_NAME)) .dest(REMOVE_FROM_GROUP_ARG_NAME) .action(Arguments.append()) .type(String.class) .nargs(2) .required(false) .metavar(USER_OR_GROUP_META_VAR, TARGET_GROUP_META_VAR) .help("The name of the user/group being removed and the group it is being removed from"); subparser.addArgument(asArg(GRANT_PERMISSION)) .dest(GRANT_PERMISSION) .action(Arguments.append()) .type(String.class) .nargs(2) .metavar(USER_OR_GROUP_META_VAR, PERMISSION_NAME_META_VAR) .help("The name of the user/group and the name of the application permission to grant to it"); subparser.addArgument(asArg(REVOKE_PERMISSION)) .dest(REVOKE_PERMISSION) .action(Arguments.append()) .type(String.class) .nargs(2) .metavar(USER_OR_GROUP_META_VAR, PERMISSION_NAME_META_VAR) .help("The name of the user/group and the name of the application permission to revoke from it"); LOGGER.info("help\n{}", subparser.formatHelp()); String[] args = new String[] { "manageUsers", asArg(CREATE_USER_ARG_NAME), "jbloggs", asArg(ADD_TO_GROUP_ARG_NAME), "jbloggs", "Administrators" }; LOGGER.info("Command: {}", String.join(" ", args)); final Namespace namespace = parser.parseArgs(args); LOGGER.info("Namespace: {}", namespace); }