@Test public void testRun() throws Exception { Shell shell = new Shell(); HelpCommand command = new HelpCommand(shell); Map<String, String> options = new HashMap<>(); List<String> args = new ArrayList<>(); command.run(new Line("help", options, args)); args = new ArrayList<>(); args.add("not-found"); command.run(new Line("help", options, args)); shell.register(new ExitCommand(shell)); args = new ArrayList<>(); args.add("exit"); command.run(new Line("help", options, args)); }
@Override public void run(Line line) throws Exception { List<String> args = line.args(); if (args.isEmpty()) { shell.console().println(usage().toString()); return; } String command = line.args().get(0); Command c = shell.commands().get(command); if (c == null) { shell.console().println("no help topic for '" + command + "'"); return; } shell.console().println(c.usage().toString()); }
HelpCommand implements Command { @Override public void run(Line line) throws Exception { List<String> args = line.args(); if (args.isEmpty()) { shell.console().println(usage().toString()); return; } String command = line.args().get(0); Command c = shell.commands().get(command); if (c == null) { shell.console().println("no help topic for '" + command + "'"); return; } shell.console().println(c.usage().toString()); } }
HelpCommand implements Command { @Override public void run(Line line) throws Exception { List<String> args = line.args(); if (args.isEmpty()) { shell.console().println(usage().toString()); return; } String command = line.args().get(0); Command c = shell.commands().get(command); if (c == null) { shell.console().println("no help topic for '" + command + "'"); return; } shell.console().println(c.usage().toString()); } HelpCommand(Shell shell); }
HelpCommand implements Command { @Override public void run(Line line) throws Exception { List<String> args = line.args(); if (args.isEmpty()) { shell.console().println(usage().toString()); return; } String command = line.args().get(0); Command c = shell.commands().get(command); if (c == null) { shell.console().println("no help topic for '" + command + "'"); return; } shell.console().println(c.usage().toString()); } HelpCommand(Shell shell); @Override String name(); @Override Usage usage(); @Override void run(Line line); }
HelpCommand implements Command { @Override public void run(Line line) throws Exception { List<String> args = line.args(); if (args.isEmpty()) { shell.console().println(usage().toString()); return; } String command = line.args().get(0); Command c = shell.commands().get(command); if (c == null) { shell.console().println("no help topic for '" + command + "'"); return; } shell.console().println(c.usage().toString()); } HelpCommand(Shell shell); @Override String name(); @Override Usage usage(); @Override void run(Line line);  }