use of org.neo4j.commandline.arguments.Arguments in project neo4j by neo4j.
the class HelpCommandTest method showsArgumentsAndDescriptionForSpecifiedCommand.
@Test
public void showsArgumentsAndDescriptionForSpecifiedCommand() throws Exception {
CommandLocator commandLocator = mock(CommandLocator.class);
AdminCommand.Provider commandProvider = mock(AdminCommand.Provider.class);
when(commandProvider.name()).thenReturn("foobar");
Arguments arguments = new Arguments().withDatabase();
when(commandProvider.allArguments()).thenReturn(arguments);
when(commandProvider.possibleArguments()).thenReturn(Collections.singletonList(arguments));
when(commandProvider.description()).thenReturn("This is a description of the foobar command.");
when(commandLocator.findProvider("foobar")).thenReturn(commandProvider);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
PrintStream ps = new PrintStream(baos);
HelpCommand helpCommand = new HelpCommand(new Usage("neo4j-admin", commandLocator), ps::println, commandLocator);
helpCommand.execute("foobar");
assertEquals(String.format("usage: neo4j-admin foobar [--database=<name>]%n" + "%n" + "This is a description of the foobar command.%n" + "%n" + "options:%n" + " --database=<name> Name of database. [default:graph.db]%n"), baos.toString());
}
}
use of org.neo4j.commandline.arguments.Arguments in project neo4j by neo4j.
the class CommandUsage method printDetailed.
void printDetailed(Consumer<String> output) {
for (Arguments arguments : command.possibleArguments()) {
String left = format("usage: %s %s", scriptName, command.name());
output.accept(Arguments.rightColumnFormatted(left, arguments.usage(), left.length() + 1));
}
output.accept("");
output.accept(command.allArguments().description(command.description()));
}
Aggregations