use of net.sourceforge.argparse4j.inf.Subparser in project atlasdb by palantir.
the class AtlasDbCliCommandTest method getArgumentMockFromAddOptionToParser.
private static Argument getArgumentMockFromAddOptionToParser(OptionMetadata metadata, String... argNames) {
Subparser parser = mock(Subparser.class);
Argument argument = mock(Argument.class, (Answer<Object>) (invocation) -> {
Object mock = invocation.getMock();
if (invocation.getMethod().getReturnType().isInstance(mock)) {
return mock;
} else {
return Mockito.RETURNS_DEFAULTS.answer(invocation);
}
});
when(parser.addArgument(argNames)).thenReturn(argument);
AtlasDbCliCommand.addOptionToParser(parser, metadata);
return argument;
}
use of net.sourceforge.argparse4j.inf.Subparser in project atlasdb by palantir.
the class AtlasDbConfiguredCommand method configure.
@Override
public void configure(Subparser subparser) {
Subparser parser = subparser.addSubparsers().addParser(consoleCommand.getName()).setDefault(COMMAND_NAME_ATTR, consoleCommand.getName()).description(consoleCommand.getDescription());
consoleCommand.configure(parser);
cliCommand.configure(subparser);
}
use of net.sourceforge.argparse4j.inf.Subparser in project dropwizard by dropwizard.
the class AbstractMigrationTest method createSubparser.
protected static Subparser createSubparser(AbstractLiquibaseCommand<?> command) {
final Subparser subparser = ArgumentParsers.newFor("db").terminalWidthDetection(false).build().addSubparsers().addParser(command.getName()).description(command.getDescription());
command.configure(subparser);
return subparser;
}
use of net.sourceforge.argparse4j.inf.Subparser in project dropwizard by dropwizard.
the class DbMigrateCommandTest method testPrintHelp.
@Test
void testPrintHelp() throws Exception {
final Subparser subparser = ArgumentParsers.newFor("db").terminalWidthDetection(false).build().addSubparsers().addParser(migrateCommand.getName()).description(migrateCommand.getDescription());
migrateCommand.configure(subparser);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
subparser.printHelp(new PrintWriter(new OutputStreamWriter(baos, UTF_8), true));
assertThat(baos.toString(UTF_8.name())).isEqualTo(String.format("usage: db migrate [-h] [--migrations MIGRATIONS-FILE] [--catalog CATALOG]%n" + " [--schema SCHEMA] [-n] [-c COUNT] [-i CONTEXTS] [file]%n" + "%n" + "Apply all pending change sets.%n" + "%n" + "positional arguments:%n" + " file application configuration file%n" + "%n" + "named arguments:%n" + " -h, --help show this help message and exit%n" + " --migrations MIGRATIONS-FILE%n" + " the file containing the Liquibase migrations for%n" + " the application%n" + " --catalog CATALOG Specify the database catalog (use database%n" + " default if omitted)%n" + " --schema SCHEMA Specify the database schema (use database default%n" + " if omitted)%n" + " -n, --dry-run output the DDL to stdout, don't run it%n" + " -c COUNT, --count COUNT%n" + " only apply the next N change sets%n" + " -i CONTEXTS, --include CONTEXTS%n" + " include change sets from the given context%n"));
}
use of net.sourceforge.argparse4j.inf.Subparser in project helios by spotify.
the class DeploymentGroupInspectCommandTest method setUp.
@Before
public void setUp() {
// use a real, dummy Subparser impl to avoid having to mock out every single call
final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
final Subparser subparser = parser.addSubparsers().addParser("inspect");
command = new DeploymentGroupInspectCommand(subparser);
when(client.deploymentGroup(NAME)).thenReturn(Futures.immediateFuture(DEPLOYMENT_GROUP));
final ListenableFuture<DeploymentGroup> nullFuture = Futures.immediateFuture(null);
when(client.deploymentGroup(NON_EXISTENT_NAME)).thenReturn(nullFuture);
}
Aggregations