Mercurial > hg > release > thermostat-0.4
changeset 651:205565370bab
Move command usage to properties file
Reviewed-by: sgehwolf
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003395.html
line wrap: on
line diff
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java Tue Oct 02 17:43:37 2012 -0400 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java Tue Oct 02 17:43:38 2012 -0400 @@ -83,10 +83,6 @@ private static final String NAME = "agent"; - // TODO: Use LocaleResources for i18n-ized strings. - - private static final String USAGE = "thermostat agent -d <url> [-u <user> -p <password>] [-s] [--debug]"; - private AgentStartupConfiguration configuration; private AgentOptionParser parser; @@ -219,11 +215,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return AgentOptionParser.getOptions(); }
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/ServiceCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/ServiceCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -61,7 +61,6 @@ public class ServiceCommand extends SimpleCommand implements ActionListener<ApplicationState> { private static final String NAME = "service"; - private static final String USAGE = "thermostat service"; private List<ActionListener<ApplicationState>> listeners; @@ -119,11 +118,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public boolean isAvailableInShell() { return false; }
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/StorageCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/StorageCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -60,8 +60,6 @@ private static final String NAME = "storage"; - private static final String USAGE = "thermostat storage <--start|--stop>"; - private DBStartupConfiguration configuration; private DBOptionParser parser; @@ -186,11 +184,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return DBOptionParser.getOptions(); }
--- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/AgentApplicationTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/AgentApplicationTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -72,9 +72,9 @@ } @Test - public void testUsage() { - String usage = agent.getUsage(); - assertEquals("thermostat agent -d <url> [-u <user> -p <password>] [-s] [--debug]", usage); + public void testDescAndUsage() { + assertNotNull(agent.getDescription()); + assertNotNull(agent.getUsage()); } @Test
--- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/DBServiceTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/DBServiceTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -244,10 +244,10 @@ } @Test - public void testUsage() { + public void testDescAndUsage() { StorageCommand dbService = new StorageCommand(); - String usage = dbService.getUsage(); - assertEquals("thermostat storage <--start|--stop>", usage); + assertNotNull(dbService.getDescription()); + assertNotNull(dbService.getUsage()); } @Test
--- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/ThermostatServiceTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/ThermostatServiceTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -67,9 +67,9 @@ } @Test - public void testUsage() { - String usage = thermostatService.getUsage(); - assertEquals("thermostat service", usage); + public void testDescAndUsage() { + assertNotNull(thermostatService.getDescription()); + assertNotNull(thermostatService.getUsage()); } @Test
--- a/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -61,7 +61,6 @@ public class PingCommand extends SimpleCommand { private static final String NAME = "ping"; - private static final String USAGE = "ping <agentId>"; private class PongListener implements RequestResponseListener { @@ -164,11 +163,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return new Options(); }
--- a/client/core/src/main/java/com/redhat/thermostat/client/internal/GUIClientCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/core/src/main/java/com/redhat/thermostat/client/internal/GUIClientCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -82,11 +82,6 @@ } @Override - public String getUsage() { - return "thermostat gui"; - } - - @Override public Options getOptions() { return new Options(); }
--- a/client/core/src/test/java/com/redhat/thermostat/client/internal/GUIClientCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/core/src/test/java/com/redhat/thermostat/client/internal/GUIClientCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -101,8 +101,9 @@ } @Test - public void testUsage() { - assertEquals("thermostat gui", cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -51,7 +51,6 @@ public class DumpHeapCommand extends SimpleCommand { private static final String NAME = "dump-heap"; - private static final String USAGE = "thermostat dump-heap --hostId <host> --vmId <vm>"; private final HeapDumperCommand implementation; @@ -69,11 +68,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return HostVMArguments.getOptions(); }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -58,7 +58,6 @@ private static final String HEAP_ID_ARG = "heapId"; private static final String LIMIT_ARG = "limit"; private static final String NAME = "find-objects"; - private static final String USAGE = "thermostat find-objects --heapId <id> --limit <limit> <pattern>"; private static final String HEADER_OBJECT_ID = Translate.localize(LocaleResources.HEADER_OBJECT_ID); private static final String HEADER_TYPE = Translate.localize(LocaleResources.HEADER_OBJECT_TYPE); private static final int DEFAULT_LIMIT = 10; @@ -110,11 +109,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { Options options = new Options();
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindRootCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindRootCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -58,7 +58,6 @@ private static final String ALL_ARG = "all"; private static final String NAME = "find-root"; - private static final String USAGE = "thermostat find-root --heapId <heap> --objectId <object> [-a]"; @Override public void run(CommandContext ctx) throws CommandException { @@ -118,11 +117,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { Options options = ObjectCommandHelper.getOptions();
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -61,7 +61,6 @@ public class ListHeapDumpsCommand extends SimpleCommand { private static final String NAME = "list-heap-dumps"; - private static final String USAGE = "same_as_desc"; // TODO localize private static final String[] COLUMN_NAMES = { @@ -77,11 +76,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return HostVMArguments.getOptions(false, false); }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -58,7 +58,6 @@ public class ObjectInfoCommand extends SimpleCommand { private static final String NAME = "object-info"; - private static final String USAGE = "thermostat object-info --heapId <heap> --objectId <object>"; private Snapshot snapshot; @@ -122,11 +121,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return ObjectCommandHelper.getOptions(); }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/SaveHeapDumpToFileCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/SaveHeapDumpToFileCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -61,7 +61,6 @@ public class SaveHeapDumpToFileCommand extends SimpleCommand { private static final String NAME = "save-heap-dump-to-file"; - private static final String USAGE = "same as desc"; private static final String HEAP_ID_ARGUMENT = "heapId"; private static final String FILE_NAME_ARGUMENT = "file"; @@ -82,11 +81,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { Options options = new Options();
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -57,7 +57,6 @@ public class ShowHeapHistogramCommand extends SimpleCommand { private static final String NAME = "show-heap-histogram"; - private static final String USAGE = "same as desc"; @Override public String getName() { @@ -65,11 +64,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { Options options = new Options();
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -62,7 +62,7 @@ Command command = new DumpHeapCommand(); assertEquals("dump-heap", command.getName()); assertNotNull(command.getDescription()); - assertEquals("thermostat dump-heap --hostId <host> --vmId <vm>", command.getUsage()); + assertNotNull(command.getUsage()); } @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -38,6 +38,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.isA; import static org.mockito.Mockito.mock; @@ -136,8 +137,9 @@ } @Test - public void testUsage() { - assertEquals("thermostat find-objects --heapId <id> --limit <limit> <pattern>", cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindRootCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindRootCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -38,6 +38,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; @@ -191,8 +192,9 @@ } @Test - public void testUsage() { - assertEquals("thermostat find-root --heapId <heap> --objectId <object> [-a]", cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -37,6 +37,7 @@ package com.redhat.thermostat.client.heap.cli; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; @@ -157,8 +158,9 @@ } @Test - public void testUsage() { - assertEquals("thermostat object-info --heapId <heap> --objectId <object>", cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -40,7 +40,6 @@ import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.junit.Test;
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/CommandInfo.java Tue Oct 02 17:43:37 2012 -0400 +++ b/common/core/src/main/java/com/redhat/thermostat/common/cli/CommandInfo.java Tue Oct 02 17:43:38 2012 -0400 @@ -8,6 +8,8 @@ public String getDescription(); + public String getUsage(); + public List<String> getDependencyResourceNames(); }
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/CommandWithInfo.java Tue Oct 02 17:43:37 2012 -0400 +++ b/common/core/src/main/java/com/redhat/thermostat/common/cli/CommandWithInfo.java Tue Oct 02 17:43:38 2012 -0400 @@ -6,9 +6,10 @@ private CommandInfo info; private static final String noDesc = "Description not available."; + private static final String noUsage = "Usage not available."; void setCommandInfo(CommandInfo info) { - this.info = info; + this.info = info; } @Override @@ -17,6 +18,7 @@ try { desc = info.getDescription(); } catch (NullPointerException infoWasNotSet) {} + if (desc == null) { desc = noDesc; } @@ -25,8 +27,14 @@ @Override public String getUsage() { - // TODO Auto-generated method stub - return null; + String usage = null; + try { + usage = info.getUsage(); + } catch (NullPointerException infoNotSet) {} + if (usage == null) { + usage = noUsage; + } + return usage; } @Override
--- a/distribution/config/commands/agent.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/agent.properties Tue Oct 02 17:43:38 2012 -0400 @@ -9,4 +9,6 @@ thermostat-thread-collector-@project.version@.jar, \ thermostat-thread-harvester-@project.version@.jar -description = starts and stops the thermostat agent \ No newline at end of file +description = starts and stops the thermostat agent + +usage = thermostat agent [-d <url> [-u <user> -p <password>]] [-s] [--debug]
--- a/distribution/config/commands/connect.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/connect.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ bundles = description = persistently connect to a database + +usage = connect -d <url> [-u <username>] [-p <password>] \ No newline at end of file
--- a/distribution/config/commands/disconnect.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/disconnect.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ bundles = description = disconnect from the currently used database + +usage = thermostat disconnect \ No newline at end of file
--- a/distribution/config/commands/dump-heap.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/dump-heap.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = trigger a heap dump on the VM + +usage = thermostat dump-heap --hostId <host> --vmId <vm>
--- a/distribution/config/commands/find-objects.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/find-objects.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = Finds objects in a heapdump + +usage = thermostat find-objects --heapId <id> --limit <limit> <pattern>
--- a/distribution/config/commands/find-root.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/find-root.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = finds the shortest path from an object to a GC root + +usage = thermostat find-root --heapId <heap> --objectId <object> [-a]
--- a/distribution/config/commands/gui.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/gui.properties Tue Oct 02 17:43:38 2012 -0400 @@ -17,3 +17,5 @@ thermostat-client-command-@project.version@.jar description = launches the GUI client + +usage = thermostat gui
--- a/distribution/config/commands/help.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/help.properties Tue Oct 02 17:43:38 2012 -0400 @@ -1,3 +1,4 @@ # HelpCommand is provided by launcher, and needs no other bundles to be loaded. bundles = description = show help for a given command or help overview +usage = thermostat help [command-name]
--- a/distribution/config/commands/list-heap-dumps.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/list-heap-dumps.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = list all heap dumps + +usage = thermostat list-heap-dumps --hostId <host> --vmId <vm>
--- a/distribution/config/commands/list-vms.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/list-vms.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ bundles = description = lists all currently monitored VMs + +usage = thermostat list-vms [-d <url> [-u <username> -p <password>]]
--- a/distribution/config/commands/object-info.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/object-info.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = prints information about an object in a heap dump + +usage = thermostat object-info --heapId <heap> --objectId <object>
--- a/distribution/config/commands/ping.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/ping.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ thermostat-client-command-@project.version@.jar description = using the Command Channel, send a ping to a running agent + +usage = ping <agentId>
--- a/distribution/config/commands/save-heap-dump-to-file.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/save-heap-dump-to-file.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = saves a heap dump to a local file + +usage = thermostat save-heap-dump-to-file --heapId <heap> --file <filename>
--- a/distribution/config/commands/service.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/service.properties Tue Oct 02 17:43:38 2012 -0400 @@ -6,3 +6,5 @@ thermostat-agent-cli-@project.version@.jar description = starts and stops the thermostat storage and agent + +usage = thermostat service
--- a/distribution/config/commands/shell.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/shell.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ bundles = description = launches the Thermostat interactive shell + +usage = thermostat shell
--- a/distribution/config/commands/show-heap-histogram.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/show-heap-histogram.properties Tue Oct 02 17:43:38 2012 -0400 @@ -7,3 +7,5 @@ thermostat-laf-@project.version@.jar description = show the heap histogram + +usage = thermostat show-heap-histogram --heapId <heap>
--- a/distribution/config/commands/storage.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/storage.properties Tue Oct 02 17:43:38 2012 -0400 @@ -6,3 +6,5 @@ thermostat-agent-command-@project.version@.jar description = starts and stops the thermostat storage + +usage = thermostat storage <--start|--stop>
--- a/distribution/config/commands/vm-info.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/vm-info.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ bundles = description = shows basic information about a VM + +usage = thermostat vm-info [--vmId <vm>] [--hostId <host>]
--- a/distribution/config/commands/vm-stat.properties Tue Oct 02 17:43:37 2012 -0400 +++ b/distribution/config/commands/vm-stat.properties Tue Oct 02 17:43:38 2012 -0400 @@ -2,3 +2,5 @@ bundles = description = show various statistics about a VM + +usage = thermostat vm-stat --hostId <host> --vmId <vm>
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/CommandInfoImpl.java Tue Oct 02 17:43:37 2012 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/CommandInfoImpl.java Tue Oct 02 17:43:38 2012 -0400 @@ -53,9 +53,9 @@ private static final Logger logger = LoggingUtils.getLogger(CommandInfoSource.class); private static final String PROPERTY_BUNDLES = "bundles"; private static final String PROPERTY_DESC = "description"; + private static final String PROPERTY_USAGE = "usage"; - private String name; - private String description; + private String name, description, usage; private List<String> dependencies; CommandInfoImpl(String name, Properties properties, String thermostatHome) { @@ -66,6 +66,8 @@ learnDependencies(entry, thermostatHome); } else if (key.equals(PROPERTY_DESC)) { description = properties.getProperty(key); + } else if (key.equals(PROPERTY_USAGE)) { + usage = properties.getProperty(key); } } @@ -97,6 +99,10 @@ return description; } + public String getUsage() { + return usage; + } + public List<String> getDependencyResourceNames() { return dependencies; }
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/HelpCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/HelpCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -58,7 +58,6 @@ private static final int COMMANDS_COLUMNS_WIDTH = 14; private static final String NAME = "help"; - private static final String USAGE = "thermostat help [command-name]"; private static final CommandComparator comparator = new CommandComparator(); @@ -118,11 +117,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return new Options(); }
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/HelpCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/HelpCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -37,6 +37,7 @@ package com.redhat.thermostat.launcher.internal; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -58,10 +59,7 @@ @Before public void setUp() { - ctxFactory = new TestCommandContextFactory(); - - } @After @@ -199,10 +197,9 @@ } @Test - public void testUsage() { + public void testDescAndUsage() { HelpCommand cmd = new HelpCommand(); - String expected = "thermostat help [command-name]"; - - assertEquals(expected, cmd.getUsage()); + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/ConnectCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/ConnectCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -64,7 +64,6 @@ public class ConnectCommand extends SimpleCommand { private static final String NAME = "connect"; - private static final String USAGE = "connect -d <url> [-u <username>] [-p <password>]"; private ClientPreferences prefs; @@ -101,11 +100,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { Options options = new Options();
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/DisconnectCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/DisconnectCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -51,7 +51,6 @@ public class DisconnectCommand extends SimpleCommand { private static final String NAME = "disconnect"; - private static final String USAGE = NAME; @SuppressWarnings("rawtypes") @Override @@ -77,11 +76,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return new Options(); }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/ListVMsCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/ListVMsCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -55,8 +55,6 @@ private static final String NAME = "list-vms"; - private static final String USAGE = "thermostat list-vms [-d <url> [-u <username> -p <password>]]"; - @Override public void run(CommandContext ctx) throws CommandException { @@ -81,11 +79,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return new Options(); }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/ShellCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/ShellCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -70,8 +70,6 @@ private static final String NAME = "shell"; - private static final String USAGE = "thermostat shell"; - private static final String PROMPT = "Thermostat > "; private HistoryProvider historyProvider; @@ -174,11 +172,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return new Options(); }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/VMInfoCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/VMInfoCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -60,7 +60,6 @@ public class VMInfoCommand extends SimpleCommand { private static final String NAME = "vm-info"; - private static final String USAGE = "thermostat vm-info [--vmId <vm>] [--hostId <host>]"; private static final String STILL_ALIVE = Translate.localize(LocaleResources.VM_STOP_TIME_RUNNING); @Override @@ -117,11 +116,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { return HostVMArguments.getOptions(false); }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java Tue Oct 02 17:43:38 2012 -0400 @@ -63,7 +63,6 @@ private static final Logger log = Logger.getLogger(VMStatCommand.class.getName()); private static final String CMD_NAME = "vm-stat"; - private static final String USAGE = "thermostat vm-stat --hostId <host> --vmId <vm>"; @Override public void run(final CommandContext ctx) throws CommandException { @@ -123,11 +122,6 @@ } @Override - public String getUsage() { - return USAGE; - } - - @Override public Options getOptions() { Options options = HostVMArguments.getOptions();
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -163,10 +163,9 @@ } @Test - public void testUsage() { - String expected = "connect -d <url> [-u <username>] [-p <password>]"; - - assertEquals(expected, cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -152,9 +152,9 @@ } @Test - public void testUsage() { - String expected = "disconnect"; - assertEquals(expected, cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ListVMsCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ListVMsCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -161,10 +161,9 @@ } @Test - public void testUsage() { - String expected = "thermostat list-vms [-d <url> [-u <username> -p <password>]]"; - - assertEquals(expected, cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ShellCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ShellCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -234,8 +234,9 @@ } @Test - public void testUsage() { - assertEquals("thermostat shell", cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -210,10 +210,9 @@ } @Test - public void testUsage() { - String expected = "thermostat vm-info [--vmId <vm>] [--hostId <host>]"; - - assertEquals(expected, cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getDescription()); + assertNotNull(cmd.getUsage()); } @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java Tue Oct 02 17:43:37 2012 -0400 +++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java Tue Oct 02 17:43:38 2012 -0400 @@ -296,8 +296,9 @@ } @Test - public void testUsage() { - assertEquals("thermostat vm-stat --hostId <host> --vmId <vm>", cmd.getUsage()); + public void testDescAndUsage() { + assertNotNull(cmd.getUsage()); + assertNotNull(cmd.getUsage()); } @Test