public void help(List<String> arguments) { CommandRunner helpCommandRunner = new CommandRunner(io, help); helpCommandRunner.run(arguments); } }
@Override public void runCommand(CliParser parser) { run(parser); }
@Override public CliCommand defineCommand() { return delegate.defineCommand(); }
@Test(groups = "fast") public void testDispatchHelp() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help"); assertResult(resultStatus, 0, EXPECTED_ALL, ""); }
public int run(List<String> arguments) { CliParser parser = new CliParser(command.defineCommand(), arguments); return run(command, parser); }
@Test(groups = "fast") public void testDispatchBogusArg() { CommandDispatcher dispatcher = createDispatcher(new FooCommand(io)); int resultStatus = dispatcher.run("bogus"); assertResult(resultStatus, -1, EXPECTED_ALL + "\n", "Unknown commandName: bogus\n"); }
@Override public void runCommand(CliParser parser) { help(parser.get("command_name"), parser.getTrailing()); } };
public T openService(HostAndPort host) { ThriftClient<T> client = createClient(); try { return openService(host, client, transport); } catch (TTransportException e) { throw new ErrorMessage(e, "Failed to connect to %s", host); } }
public static CommandRunner printStackTraces(IO io, CommandBuilder command) { return new CommandRunner(io, command, true); }
public int run(CliParser parser) { List<String> arguments = parser.getTrailing(); return commandDispatcher.run(arguments); } }
@Override public int read() { try { return reader.read(); } catch (IOException e) { throw new ErrorMessage(e, "Error reading input"); } }
@Override public void runCommand(CliParser parser) { delegate.runCommand(parser); }
public void help(List<String> arguments) { commandDispatcher.help(arguments); }
@Test(groups = "fast") public void testDispatchHelpHelp() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help", "help"); assertResult(resultStatus, 0, EXPECTED_HELP, ""); }
@Override public String readLine() { try { return reader.readLine(); } catch (IOException e) { throw new ErrorMessage(e, "Error reading input"); } }
@Test(groups = "fast") public void testDispatchHelpFoo() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help", "foo"); assertResult(resultStatus, 0, EXPECTED_FOO, ""); }
@Test(groups = "fast") public void testDispatchFoo() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo", "--bar", "test"); assertResult(resultStatus, 0, "I am foo\n", "oof ma I\n"); }
@Test(groups = "fast") public void testDispatchNoArgs() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run(); assertResult(resultStatus, 0, EXPECTED_ALL, ""); }
@Test(groups = "fast") public void testDispatchFooMissingRequired() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo"); assertResult(resultStatus, -1, EXPECTED_FOO + "\n", "Missing required option: --bar\n"); }
@Test(groups = "fast") public void testDuplicateArg() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo", "-b", "bar", "--bar=baz"); assertResult(resultStatus, -1, EXPECTED_FOO + "\n", "Duplicate options: -b=bar, --bar=baz\n"); }