@Test public void testUnknownParametersAreErrors() { setParameters.execute("set", "unknown"); verify(mockConsoleIO).writeError("Unknown parameter: unknown"); verifyNoMoreInteractions(mockConsoleIO); }
@Override public void execute(String... tokens) { switch (tokens.length) { case 0: consoleIO.writeln(getHelpLong()); break; case 1: for (String setting : settings.keySet()) { showSetting(setting); } break; default: String param = tokens[1]; int eqIdx = param.indexOf('='); if (eqIdx < 0) { showSetting(param); } else { String key = param.substring(0, eqIdx); String values = String.join(" ", tokens); eqIdx = values.indexOf('='); setParameter(key, values.substring(eqIdx + 1)); } } }
SetParameters extends ConsoleCommand { @Override public void execute(String... tokens) { switch (tokens.length) { case 0: consoleIO.writeln(getHelpLong()); break; case 1: for (String setting : settings.keySet()) { showSetting(setting); } break; default: String param = tokens[1]; int eqIdx = param.indexOf('='); if (eqIdx < 0) { showSetting(param); } else { String key = param.substring(0, eqIdx); String values = String.join(" ", tokens); eqIdx = values.indexOf('='); setParameter(key, values.substring(eqIdx + 1)); } } } }
SetParameters extends ConsoleCommand { @Override public void execute(String... tokens) { switch (tokens.length) { case 0: consoleIO.writeln(getHelpLong()); break; case 1: for (String setting : settings.keySet()) { showSetting(setting); } break; default: String param = tokens[1]; int eqIdx = param.indexOf('='); if (eqIdx < 0) { showSetting(param); } else { String key = param.substring(0, eqIdx); String values = String.join(" ", tokens); eqIdx = values.indexOf('='); setParameter(key, values.substring(eqIdx + 1)); } } } SetParameters(ConsoleIO consoleIO, ConsoleState state, Map<String, ConsoleSetting> settings); }
SetParameters extends ConsoleCommand { @Override public void execute(String... tokens) { switch (tokens.length) { case 0: consoleIO.writeln(getHelpLong()); break; case 1: for (String setting : settings.keySet()) { showSetting(setting); } break; default: String param = tokens[1]; int eqIdx = param.indexOf('='); if (eqIdx < 0) { showSetting(param); } else { String key = param.substring(0, eqIdx); String values = String.join(" ", tokens); eqIdx = values.indexOf('='); setParameter(key, values.substring(eqIdx + 1)); } } } SetParameters(ConsoleIO consoleIO, ConsoleState state, Map<String, ConsoleSetting> settings); @Override String getName(); @Override String getHelpShort(); @Override String getHelpLong(); @Override void execute(String... tokens); }
SetParameters extends ConsoleCommand { @Override public void execute(String... tokens) { switch (tokens.length) { case 0: consoleIO.writeln(getHelpLong()); break; case 1: for (String setting : settings.keySet()) { showSetting(setting); } break; default: String param = tokens[1]; int eqIdx = param.indexOf('='); if (eqIdx < 0) { showSetting(param); } else { String key = param.substring(0, eqIdx); String values = String.join(" ", tokens); eqIdx = values.indexOf('='); setParameter(key, values.substring(eqIdx + 1)); } } } SetParameters(ConsoleIO consoleIO, ConsoleState state, Map<String, ConsoleSetting> settings); @Override String getName(); @Override String getHelpShort(); @Override String getHelpLong(); @Override void execute(String... tokens);  }