changeset 649:73c182a706fc

Remove ArgumentSpec entirely Reviewed-by: sgehwolf Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003396.html
author Jon VanAlten <vanaltj@gmail.com>
date Tue, 02 Oct 2012 17:43:25 -0400
parents 8cc8dea8b9d6
children 486a299ab905
files agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java agent/cli/src/main/java/com/redhat/thermostat/agent/cli/ServiceCommand.java agent/cli/src/main/java/com/redhat/thermostat/agent/cli/StorageCommand.java agent/cli/src/main/java/com/redhat/thermostat/agent/cli/db/DBOptionParser.java agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/locale/LocaleResources.java agent/cli/src/main/resources/com/redhat/thermostat/agent/cli/impl/strings.properties agent/cli/src/test/java/com/redhat/thermostat/agent/cli/AgentApplicationTest.java agent/cli/src/test/java/com/redhat/thermostat/agent/cli/DBServiceTest.java agent/cli/src/test/java/com/redhat/thermostat/agent/cli/ThermostatServiceTest.java agent/core/src/main/java/com/redhat/thermostat/agent/config/AgentOptionParser.java client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java client/core/src/main/java/com/redhat/thermostat/client/internal/GUIClientCommand.java client/core/src/test/java/com/redhat/thermostat/client/internal/GUIClientCommandTest.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommand.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommand.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindRootCommand.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommand.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectCommandHelper.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommand.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/SaveHeapDumpToFileCommand.java client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommand.java client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommandTest.java client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindRootCommandTest.java client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommandTest.java client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommandTest.java common/core/src/main/java/com/redhat/thermostat/common/cli/ArgumentSpec.java common/core/src/main/java/com/redhat/thermostat/common/cli/Command.java common/core/src/main/java/com/redhat/thermostat/common/cli/HostVMArguments.java common/core/src/main/java/com/redhat/thermostat/common/cli/SimpleArgumentSpec.java common/core/src/test/java/com/redhat/thermostat/common/cli/HostVMArgumentsTest.java common/core/src/test/java/com/redhat/thermostat/common/cli/SimpleArgumentSpecTest.java common/core/src/test/java/com/redhat/thermostat/common/tools/BasicCommandTest.java common/test/src/main/java/com/redhat/thermostat/test/cli/TestCommand.java launcher/src/main/java/com/redhat/thermostat/launcher/CommonCommandOptions.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/CommandLineArgumentsParser.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/HelpCommand.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/LaunchUtils.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java launcher/src/test/java/com/redhat/thermostat/launcher/CommonCommandOptionsTest.java launcher/src/test/java/com/redhat/thermostat/launcher/LauncherTest.java launcher/src/test/java/com/redhat/thermostat/launcher/internal/CommandLineArgumentsParserTest.java tools/src/main/java/com/redhat/thermostat/tools/cli/ConnectCommand.java tools/src/main/java/com/redhat/thermostat/tools/cli/DisconnectCommand.java tools/src/main/java/com/redhat/thermostat/tools/cli/ListVMsCommand.java tools/src/main/java/com/redhat/thermostat/tools/cli/ShellCommand.java tools/src/main/java/com/redhat/thermostat/tools/cli/VMInfoCommand.java tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/ListVMsCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/ShellCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java
diffstat 53 files changed, 580 insertions(+), 827 deletions(-) [+]
line wrap: on
line diff
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,11 +36,12 @@
 
 package com.redhat.thermostat.agent.cli;
 
-import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.agent.Agent;
 import com.redhat.thermostat.agent.command.ConfigurationServer;
 import com.redhat.thermostat.agent.config.AgentConfigsUtils;
@@ -53,7 +54,6 @@
 import com.redhat.thermostat.common.ThreadPoolTimerFactory;
 import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -230,8 +230,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return AgentOptionParser.getAcceptedArguments();
+    public Options getOptions() {
+        return AgentOptionParser.getOptions();
     }
     
     // Does not need a reference of the enclosing type so lets declare this class static
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/ServiceCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/ServiceCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,20 +37,18 @@
 package com.redhat.thermostat.agent.cli;
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.Semaphore;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.agent.cli.db.StorageAlreadyRunningException;
 import com.redhat.thermostat.agent.cli.impl.locale.LocaleResources;
 import com.redhat.thermostat.agent.cli.impl.locale.Translate;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.tools.ApplicationState;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -137,10 +135,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        ArgumentSpec start = new SimpleArgumentSpec("start", Translate.localize(LocaleResources.COMMAND_SERVICE_ARGUMENT_START_DESCRIPTION));
-        ArgumentSpec stop = new SimpleArgumentSpec("stop", Translate.localize(LocaleResources.COMMAND_SERVICE_ARGUMENT_STOP_DESCRIPTION));
-        return Arrays.asList(start, stop);
+    public Options getOptions() {
+        return new Options();
     }
 
     @Override
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/StorageCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/StorageCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -39,16 +39,16 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.Collection;
 import java.util.Properties;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.agent.cli.db.DBConfig;
 import com.redhat.thermostat.agent.cli.db.DBOptionParser;
 import com.redhat.thermostat.agent.cli.db.DBStartupConfiguration;
 import com.redhat.thermostat.agent.cli.db.MongoProcessRunner;
 import com.redhat.thermostat.agent.cli.impl.locale.LocaleResources;
 import com.redhat.thermostat.agent.cli.impl.locale.Translate;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -200,8 +200,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return DBOptionParser.getAcceptedArguments();
+    public Options getOptions() {
+        return DBOptionParser.getOptions();
     }
 
 }
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/db/DBOptionParser.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/db/DBOptionParser.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,12 +36,11 @@
 
 package com.redhat.thermostat.agent.cli.db;
 
-import java.util.Arrays;
-import java.util.Collection;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.agent.cli.impl.locale.LocaleResources;
 import com.redhat.thermostat.agent.cli.impl.locale.Translate;
 import com.redhat.thermostat.common.config.InvalidConfigurationException;
@@ -67,7 +66,7 @@
     
     @Override
     public void parse() throws InvalidConfigurationException {
-        
+
         if (args.hasArgument(DBArgs.START.option)) {
             serviceAction = DBArgs.START;
         } else if (args.hasArgument(DBArgs.STOP.option)) {
@@ -125,11 +124,31 @@
         return quiet;
     }
 
-    public static Collection<ArgumentSpec> getAcceptedArguments() {
-        ArgumentSpec dryRun = new SimpleArgumentSpec(DBArgs.DRY.option, "d", DBArgs.DRY.description, false, false);
-        ArgumentSpec start = new SimpleArgumentSpec(DBArgs.START.option, DBArgs.START.description);
-        ArgumentSpec stop = new SimpleArgumentSpec(DBArgs.STOP.option, DBArgs.STOP.description);
-        ArgumentSpec quiet = new SimpleArgumentSpec(DBArgs.QUIET.option, "q", DBArgs.QUIET.description, false, false);
-        return Arrays.asList(dryRun, start, stop, quiet);
+    public static Options getOptions() {
+        Options options = new Options();
+
+        // TODO set default values here instead of needing to check if present later.
+        Option dryRunOption = new Option("d", DBArgs.DRY.option, false, DBArgs.DRY.description);
+        dryRunOption.setRequired(false);
+        options.addOption(dryRunOption);
+
+        OptionGroup startStopGroup = new OptionGroup();
+        startStopGroup.setRequired(true);
+
+        Option startOption = new Option("s", DBArgs.START.option, false, DBArgs.START.description);
+        startOption.setRequired(false);
+        startStopGroup.addOption(startOption);
+
+        Option stopOption = new Option("p", DBArgs.STOP.option, false, DBArgs.STOP.description);
+        stopOption.setRequired(false);
+        startStopGroup.addOption(stopOption);
+
+        options.addOptionGroup(startStopGroup);
+
+        Option quietOption = new Option("q", DBArgs.QUIET.option, false, DBArgs.QUIET.description);
+        quietOption.setRequired(false);
+        options.addOption(quietOption);
+
+        return options;
     }
 }
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/locale/LocaleResources.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/impl/locale/LocaleResources.java	Tue Oct 02 17:43:25 2012 -0400
@@ -39,8 +39,6 @@
 public enum LocaleResources {
 
     COMMAND_SERVICE_DESCRIPTION,
-    COMMAND_SERVICE_ARGUMENT_START_DESCRIPTION,
-    COMMAND_SERVICE_ARGUMENT_STOP_DESCRIPTION,
 
     STARTING_AGENT,
 
--- a/agent/cli/src/main/resources/com/redhat/thermostat/agent/cli/impl/strings.properties	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/main/resources/com/redhat/thermostat/agent/cli/impl/strings.properties	Tue Oct 02 17:43:25 2012 -0400
@@ -1,6 +1,4 @@
-COMMAND_SERVICE_DESCRIPTION = starts and stops the thermostat storage and agent
-COMMAND_SERVICE_ARGUMENT_START_DESCRIPTION = start the database and agent
-COMMAND_SERVICE_ARGUMENT_STOP_DESCRIPTION = stop the database and agent
+COMMAND_SERVICE_DESCRIPTION = starts thermostat storage and agent
 
 STARTING_AGENT = starting agent now...
 
--- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/AgentApplicationTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/AgentApplicationTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,18 +37,17 @@
 package com.redhat.thermostat.agent.cli;
 
 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 java.util.Collection;
-
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 import com.redhat.thermostat.agent.cli.AgentApplication;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 
 public class AgentApplicationTest {
 
@@ -85,14 +84,41 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = agent.getAcceptedArguments();
-        assertNotNull(args);
-        assertEquals(5, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("saveOnExit", "s", "save the data on exit", false, false)));
-        assertTrue(args.contains(new SimpleArgumentSpec("debug", "launch with debug console enabled")));
-        assertTrue(args.contains(new SimpleArgumentSpec("dbUrl", "d", "connect to the given url", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("username", "the username to use for authentication", false, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("password", "the password to use for authentication", false, true)));
+    public void testOptions() {
+        Options options = agent.getOptions();
+        assertNotNull(options);
+        assertEquals(5, options.getOptions().size());
+
+        assertTrue(options.hasOption("saveOnExit"));
+        Option save = options.getOption("saveOnExit");
+        assertEquals("s", save.getOpt());
+        assertEquals("save the data on exit", save.getDescription());
+        assertFalse(save.isRequired());
+        assertFalse(save.hasArg());
+
+        assertTrue(options.hasOption("debug"));
+        Option debug = options.getOption("debug");
+        assertEquals("launch with debug console enabled", debug.getDescription());
+        assertFalse(debug.isRequired());
+        assertFalse(debug.hasArg());
+
+        assertTrue(options.hasOption("dbUrl"));
+        Option db = options.getOption("dbUrl");
+        assertEquals("d", db.getOpt());
+        assertEquals("connect to the given url", db.getDescription());
+        assertTrue(db.isRequired());
+        assertTrue(db.hasArg());
+
+        assertTrue(options.hasOption("username"));
+        Option user = options.getOption("username");
+        assertEquals("the username to use for authentication", user.getDescription());
+        assertFalse(user.isRequired());
+        assertTrue(user.hasArg());
+
+        assertTrue(options.hasOption("password"));
+        Option pass = options.getOption("password");
+        assertEquals("the password to use for authentication", pass.getDescription());
+        assertFalse(pass.isRequired());
+        assertTrue(pass.hasArg());
     }
 }
--- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/DBServiceTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/DBServiceTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,6 +37,7 @@
 package com.redhat.thermostat.agent.cli;
 
 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.doThrow;
@@ -53,6 +54,9 @@
 
 import junit.framework.Assert;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -62,10 +66,8 @@
 import com.redhat.thermostat.agent.cli.db.MongoProcessRunner;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.config.InvalidConfigurationException;
 import com.redhat.thermostat.common.tools.ApplicationException;
@@ -256,14 +258,44 @@
     }
 
     @Test
-    public void testArguments() {
+    public void testOptions() {
         StorageCommand dbService = new StorageCommand();
-        Collection<ArgumentSpec> args = dbService.getAcceptedArguments();
-        assertNotNull(args);
-        assertEquals(4, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("dryRun", "d", "run the service in dry run mode", false, false)));
-        assertTrue(args.contains(new SimpleArgumentSpec("start", "start the database")));
-        assertTrue(args.contains(new SimpleArgumentSpec("stop", "stop the database")));
-        assertTrue(args.contains(new SimpleArgumentSpec("quiet", "q", "don't produce any output", false, false)));
+        Options options = dbService.getOptions();
+        assertNotNull(options);
+        assertEquals(4, options.getOptions().size());
+
+        assertTrue(options.hasOption("dryRun"));
+        Option dry = options.getOption("dryRun");
+        assertEquals("d", dry.getOpt());
+        assertEquals("run the service in dry run mode", dry.getDescription());
+        assertFalse(dry.isRequired());
+        assertFalse(dry.hasArg());
+
+        assertTrue(options.hasOption("start"));
+        Option start = options.getOption("start");
+        assertEquals("start the database", start.getDescription());
+        assertFalse(start.isRequired());
+        assertFalse(start.hasArg());
+
+        assertTrue(options.hasOption("stop"));
+        Option stop = options.getOption("stop");
+        assertEquals("stop the database", stop.getDescription());
+        assertFalse(stop.isRequired());
+        assertFalse(stop.hasArg());
+
+        assertTrue(options.hasOption("quiet"));
+        Option quiet = options.getOption("quiet");
+        assertEquals("q", quiet.getOpt());
+        assertEquals("don't produce any output", quiet.getDescription());
+        assertFalse(quiet.isRequired());
+        assertFalse(quiet.hasArg());
+
+        OptionGroup startStop = options.getOptionGroup(start);
+        assertTrue(startStop.isRequired());
+        @SuppressWarnings("unchecked")
+        Collection<Option> groupOpts = startStop.getOptions();
+        assertEquals(2, groupOpts.size());
+        assertTrue(groupOpts.contains(start));
+        assertTrue(groupOpts.contains(stop));
     }
 }
--- a/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/ThermostatServiceTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/cli/src/test/java/com/redhat/thermostat/agent/cli/ThermostatServiceTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,17 +38,13 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
-import java.util.Collection;
-
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 import com.redhat.thermostat.agent.cli.ServiceCommand;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 
 public class ThermostatServiceTest {
 
@@ -73,20 +69,19 @@
     @Test
     public void testDescription() {
         String desc = thermostatService.getDescription();
-        assertEquals("starts and stops the thermostat storage and agent", desc);
+        assertEquals("starts thermostat storage and agent", desc);
     }
 
     @Test
     public void testUsage() {
         String usage = thermostatService.getUsage();
-        assertEquals("starts and stops the thermostat storage and agent", usage);
+        assertEquals("starts thermostat storage and agent", usage);
     }
 
     @Test
-    public void testArgumentSpecs() {
-        Collection<ArgumentSpec> args = thermostatService.getAcceptedArguments();
-        assertNotNull(args);
-        assertTrue(args.contains(new SimpleArgumentSpec("start", "start the database and agent")));
-        assertTrue(args.contains(new SimpleArgumentSpec("stop", "stop the database and agent")));
+    public void testOptions() {
+        Options options = thermostatService.getOptions();
+        assertNotNull(options);
+        assertEquals(0, options.getOptions().size());
     }
 }
--- a/agent/core/src/main/java/com/redhat/thermostat/agent/config/AgentOptionParser.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/agent/core/src/main/java/com/redhat/thermostat/agent/config/AgentOptionParser.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,12 +36,10 @@
 
 package com.redhat.thermostat.agent.config;
 
-import java.util.Arrays;
-import java.util.Collection;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.config.InvalidConfigurationException;
 import com.redhat.thermostat.common.config.ThermostatOptionParser;
 
@@ -105,12 +103,29 @@
         }
     }
 
-    public static Collection<ArgumentSpec> getAcceptedArguments() {
-        ArgumentSpec saveOnExit = new SimpleArgumentSpec(Args.SAVE_ON_EXIT.option, "s", Args.SAVE_ON_EXIT.description, false, false);
-        ArgumentSpec db = new SimpleArgumentSpec(Args.DB.option, "d",  Args.DB.description, true, true);
-        ArgumentSpec username = new SimpleArgumentSpec(Args.USERNAME.option, Args.USERNAME.description, false, true);
-        ArgumentSpec password = new SimpleArgumentSpec(Args.PASSWORD.option, Args.PASSWORD.description, false, true);
-        ArgumentSpec debug = new SimpleArgumentSpec(Args.DEBUG.option, Args.DEBUG.description);
-        return Arrays.asList(saveOnExit, db, debug, username, password);
+    public static Options getOptions() {
+        Options options = new Options();
+
+        Option saveOnExitOption = new Option("s", Args.SAVE_ON_EXIT.option, false, Args.SAVE_ON_EXIT.description);
+        saveOnExitOption.setRequired(false);
+        options.addOption(saveOnExitOption);
+
+        Option dbOption = new Option("d", Args.DB.option, true, Args.DB.description);
+        dbOption.setRequired(true);
+        options.addOption(dbOption);
+
+        Option usernameOption = new Option("u", Args.USERNAME.option, true, Args.USERNAME.description);
+        usernameOption.setRequired(false);
+        options.addOption(usernameOption);
+
+        Option passwordOption = new Option("p", Args.PASSWORD.option, true, Args.PASSWORD.description);
+        passwordOption.setRequired(false);
+        options.addOption(passwordOption);
+
+        Option debugOption = new Option("v", Args.DEBUG.option, false, Args.DEBUG.description);
+        debugOption.setRequired(false);
+        options.addOption(debugOption);
+
+        return options;
     }
 }
--- a/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,14 +38,13 @@
 
 import java.io.PrintStream;
 import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.Semaphore;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.client.command.RequestQueue;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -176,9 +175,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        List<ArgumentSpec> args = new ArrayList<>();
-        return args;
+    public Options getOptions() {
+        return new Options();
     }
 
 }
--- a/client/core/src/main/java/com/redhat/thermostat/client/internal/GUIClientCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/core/src/main/java/com/redhat/thermostat/client/internal/GUIClientCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,12 +36,9 @@
 
 package com.redhat.thermostat.client.internal;
 
-import java.util.Collection;
-import java.util.Collections;
 
+import org.apache.commons.cli.Options;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
 
 import com.redhat.thermostat.client.internal.osgi.ApplicationServiceProvider;
 import com.redhat.thermostat.client.internal.osgi.ContextActionServiceProvider;
@@ -49,7 +46,6 @@
 import com.redhat.thermostat.client.locale.Translate;
 import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.osgi.service.ContextAction;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.OSGiContext;
@@ -98,8 +94,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return Collections.emptyList();
+    public Options getOptions() {
+        return new Options();
     }
 
     @Override
--- a/client/core/src/test/java/com/redhat/thermostat/client/internal/GUIClientCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/core/src/test/java/com/redhat/thermostat/client/internal/GUIClientCommandTest.java	Tue Oct 02 17:43:25 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.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.isNotNull;
@@ -47,6 +48,7 @@
 
 import java.util.Dictionary;
 
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -109,8 +111,10 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        assertEquals(0, cmd.getAcceptedArguments().size());
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertEquals(0, options.getOptions().size());
     }
 
     @Test
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/DumpHeapCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,12 +36,12 @@
 
 package com.redhat.thermostat.client.heap.cli;
 
-import java.util.Collection;
 import java.util.concurrent.Semaphore;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.Translate;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.HostVMArguments;
@@ -80,8 +80,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return HostVMArguments.getArgumentSpecs();
+    public Options getOptions() {
+        return HostVMArguments.getOptions();
     }
 
     @Override
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,16 +36,16 @@
 
 package com.redhat.thermostat.client.heap.cli;
 
-import java.util.Arrays;
 import java.util.Collection;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.Translate;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.cli.TableRenderer;
 import com.redhat.thermostat.common.dao.HeapDAO;
@@ -120,10 +120,18 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        ArgumentSpec heapIdArg = new SimpleArgumentSpec(HEAP_ID_ARG, Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION), true, true);
-        ArgumentSpec limitArg = new SimpleArgumentSpec(LIMIT_ARG, "l", Translate.localize(LocaleResources.ARGUMENT_LIMIT_DESCRIPTION, String.valueOf(DEFAULT_LIMIT)), false, true);
-        return Arrays.asList(heapIdArg, limitArg);
+    public Options getOptions() {
+        Options options = new Options();
+
+        Option heapIdOption = new Option("h", HEAP_ID_ARG, true, Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION));
+        heapIdOption.setRequired(true);
+        options.addOption(heapIdOption);
+
+        Option limitOption = new Option("l", LIMIT_ARG, true, Translate.localize(LocaleResources.ARGUMENT_LIMIT_DESCRIPTION, String.valueOf(DEFAULT_LIMIT)));
+        limitOption.setRequired(false);
+        options.addOption(limitOption);
+
+        return options;
     }
 
 }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindRootCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/FindRootCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,17 +37,17 @@
 package com.redhat.thermostat.client.heap.cli;
 
 import java.io.PrintStream;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.PrintObjectUtils;
 import com.redhat.thermostat.client.heap.Translate;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.sun.tools.hat.internal.model.JavaHeapObject;
@@ -128,11 +128,15 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        Collection<ArgumentSpec> commonObjArgs = ObjectCommandHelper.getArgumentSpecs();
-        Collection<ArgumentSpec> args = new ArrayList<>(commonObjArgs);
-        args.add(new SimpleArgumentSpec(ALL_ARG, "a", Translate.localize(LocaleResources.COMMAND_FIND_ROOT_ARGUMENT_ALL), false, false));
-        return args;
+    public Options getOptions() {
+
+        Options options = ObjectCommandHelper.getOptions();
+
+        Option allOption = new Option("a", ALL_ARG, false, Translate.localize(LocaleResources.COMMAND_FIND_ROOT_ARGUMENT_ALL));
+        allOption.setRequired(false);
+        options.addOption(allOption);
+
+        return options;
     }
 
 }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -40,10 +40,11 @@
 import java.util.Collection;
 import java.util.Date;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.Translate;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.HostVMArguments;
@@ -87,8 +88,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return HostVMArguments.getArgumentSpecs(false, false);
+    public Options getOptions() {
+        return HostVMArguments.getOptions(false, false);
     }
 
     @Override
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectCommandHelper.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectCommandHelper.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,17 +36,16 @@
 
 package com.redhat.thermostat.client.heap.cli;
 
-import java.util.Arrays;
-import java.util.Collection;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.Translate;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.dao.HeapDAO;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.redhat.thermostat.common.model.HeapInfo;
@@ -93,9 +92,17 @@
         return obj;
     }
 
-    static Collection<ArgumentSpec> getArgumentSpecs() {
-        ArgumentSpec heapIdArg = new SimpleArgumentSpec(HEAP_ID_ARG, Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION), true, true);
-        ArgumentSpec objectIdArg = new SimpleArgumentSpec(OBJECT_ID_ARG, Translate.localize(LocaleResources.ARGUMENT_OBJECT_ID_DESCRIPTION), true, true);
-        return Arrays.asList(heapIdArg, objectIdArg);
+    static Options getOptions() {
+        Options options = new Options();
+
+        Option heapIdOption = new Option("h", HEAP_ID_ARG, true, Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION));
+        heapIdOption.setRequired(true);
+        options.addOption(heapIdOption);
+
+        Option objectIdOption = new Option("o", OBJECT_ID_ARG, true, Translate.localize(LocaleResources.ARGUMENT_OBJECT_ID_DESCRIPTION));
+        objectIdOption.setRequired(true);
+        options.addOption(objectIdOption);
+
+        return options;
     }
 }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,13 +37,13 @@
 package com.redhat.thermostat.client.heap.cli;
 
 import java.io.PrintStream;
-import java.util.Collection;
 import java.util.Enumeration;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.PrintObjectUtils;
 import com.redhat.thermostat.client.heap.Translate;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleCommand;
@@ -132,8 +132,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return ObjectCommandHelper.getArgumentSpecs();
+    public Options getOptions() {
+        return ObjectCommandHelper.getOptions();
     }
 
 }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/SaveHeapDumpToFileCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/SaveHeapDumpToFileCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -43,18 +43,16 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.Translate;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.dao.HeapDAO;
 import com.redhat.thermostat.common.model.HeapInfo;
@@ -95,12 +93,19 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        List<ArgumentSpec> args = new ArrayList<>();
-        args.add(new SimpleArgumentSpec(HEAP_ID_ARGUMENT, "i", Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION), true, true));
-        args.add(new SimpleArgumentSpec(FILE_NAME_ARGUMENT, "f", Translate.localize(LocaleResources.ARGUMENT_FILE_NAME_DESCRIPTION), true, true));
+    public Options getOptions() {
+
+        Options options = new Options();
 
-        return args;
+        Option heapOption = new Option("i", HEAP_ID_ARGUMENT, true, Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION));
+        heapOption.setRequired(true);
+        options.addOption(heapOption);
+
+        Option fileOption = new Option("f", FILE_NAME_ARGUMENT, true, Translate.localize(LocaleResources.ARGUMENT_FILE_NAME_DESCRIPTION));
+        fileOption.setRequired(true);
+        options.addOption(fileOption);
+
+        return options;
     }
 
     @Override
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/cli/ShowHeapHistogramCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,18 +37,16 @@
 package com.redhat.thermostat.client.heap.cli;
 
 import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
 import com.redhat.thermostat.client.heap.LocaleResources;
 import com.redhat.thermostat.client.heap.Translate;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.cli.TableRenderer;
 import com.redhat.thermostat.common.dao.HeapDAO;
@@ -78,10 +76,14 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        List<ArgumentSpec> args = new ArrayList<>();
-        args.add(new SimpleArgumentSpec("heapId", "heapId", Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION), true, true));
-        return args;
+    public Options getOptions() {
+        Options options = new Options();
+
+        Option heapOption = new Option("i", "heapId", true, Translate.localize(LocaleResources.ARGUMENT_HEAP_ID_DESCRIPTION));
+        heapOption.setRequired(true);
+        options.addOption(heapOption);
+
+        return options;
     }
 
     @Override
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindObjectsCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,14 +37,16 @@
 package com.redhat.thermostat.client.heap.cli;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.isA;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -52,9 +54,7 @@
 import com.redhat.thermostat.client.heap.cli.FindObjectsCommand;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.dao.HeapDAO;
@@ -146,11 +146,21 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertEquals(2, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("heapId", "the ID of the heapdump to analyze", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("limit", "l", "limit search to top N results, defaults to 10", false, true)));
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertEquals(2, options.getOptions().size());
+
+        assertTrue(options.hasOption("heapId"));
+        Option heapOption = options.getOption("heapId");
+        assertEquals("the ID of the heapdump to analyze", heapOption.getDescription());
+        assertTrue(heapOption.isRequired());
+        assertTrue(heapOption.hasArg());
+
+        assertTrue(options.hasOption("limit"));
+        Option limitOption = options.getOption("limit");
+        assertEquals("limit search to top N results, defaults to 10", limitOption.getDescription());
+        assertFalse(limitOption.isRequired());
+        assertTrue(limitOption.hasArg());
     }
 
     @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindRootCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/FindRootCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,6 +37,7 @@
 package com.redhat.thermostat.client.heap.cli;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
@@ -47,6 +48,8 @@
 import java.util.Collection;
 import java.util.Enumeration;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -57,9 +60,7 @@
 import com.redhat.thermostat.client.heap.cli.HeapNotFoundException;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.dao.HeapDAO;
@@ -200,12 +201,32 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertEquals(3, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("heapId", "the ID of the heapdump to analyze", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("objectId", "the ID of the object to query", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("all", "a", "finds all paths to GC roots", false, false)));
+    public void testOptions() {
+        String heapIdOption = "heapId";
+        String objectIdOption = "objectId";
+        String allOption = "all";
+        Options options = cmd.getOptions();
+        @SuppressWarnings("unchecked")
+        Collection<Options> theOptions = options.getOptions();
+        assertEquals(3, theOptions.size());
+
+        assertTrue(options.hasOption(heapIdOption));
+        Option heapOption = options.getOption(heapIdOption);
+        assertEquals("the ID of the heapdump to analyze", heapOption.getDescription());
+        assertTrue(heapOption.isRequired());
+        assertTrue(heapOption.hasArg());
+
+        assertTrue(options.hasOption(objectIdOption));
+        Option objectOption = options.getOption(objectIdOption);
+        assertEquals("the ID of the object to query", objectOption.getDescription());
+        assertTrue(heapOption.isRequired());
+        assertTrue(heapOption.hasArg());
+
+        assertTrue(options.hasOption(allOption));
+        Option all = options.getOption(allOption);
+        assertEquals("finds all paths to GC roots", all.getDescription());
+        assertFalse(all.isRequired());
+        assertFalse(all.hasArg());
     }
 
     @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -42,12 +42,11 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.List;
 import java.util.TimeZone;
 
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -56,7 +55,6 @@
 
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
@@ -104,10 +102,11 @@
     }
 
     @Test
-    public void verifyArguments() {
+    public void verifyOptions() {
         Command command = new ListHeapDumpsCommand();
-        List<ArgumentSpec> arguments = new ArrayList<>(command.getAcceptedArguments());
-        assertEquals(2, arguments.size());
+        Options options = command.getOptions();
+        assertNotNull(options);
+        assertEquals(2, options.getOptions().size());
     }
 
     @Test
--- a/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/client/heapdumper/src/test/java/com/redhat/thermostat/client/heap/cli/ObjectInfoCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -45,9 +45,10 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.Collection;
 import java.util.Enumeration;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -58,9 +59,7 @@
 import com.redhat.thermostat.client.heap.cli.ObjectInfoCommand;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.dao.HeapDAO;
@@ -168,11 +167,21 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertEquals(2, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("heapId", "the ID of the heapdump to analyze", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("objectId", "the ID of the object to query", true, true)));
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertEquals(2, options.getOptions().size());
+
+        assertTrue(options.hasOption("heapId"));
+        Option heapOption = options.getOption("heapId");
+        assertEquals("the ID of the heapdump to analyze", heapOption.getDescription());
+        assertTrue(heapOption.isRequired());
+        assertTrue(heapOption.hasArg());
+
+        assertTrue(options.hasOption("objectId"));
+        Option objOption = options.getOption("objectId");
+        assertEquals("the ID of the object to query", objOption.getDescription());
+        assertTrue(objOption.isRequired());
+        assertTrue(objOption.hasArg());
     }
 
     @Test
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/ArgumentSpec.java	Tue Oct 02 17:37:10 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.cli;
-
-public interface ArgumentSpec {
-
-    /**
-     * Return the name of the argument. This is used as the long option,
-     * e.g. a name of 'dbUrl' results in an option --dbUrl.
-     */
-    String getName();
-
-    /**
-     * Returns the short option version of the argument, e.g. 'd' results
-     * in an option -d.
-     */
-    String getShortOption();
-
-    boolean isRequired();
-
-    boolean isUsingAdditionalArgument();
-
-    String getDescription();
-
-}
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/Command.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/common/core/src/main/java/com/redhat/thermostat/common/cli/Command.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,7 +36,7 @@
 
 package com.redhat.thermostat.common.cli;
 
-import java.util.Collection;
+import org.apache.commons.cli.Options;
 
 /**
  * Represents a command on the command line.
@@ -77,11 +77,11 @@
     public String getUsage();
 
     /**
-     * Returns a collection of arguments that the command is prepared to handle.
+     * Returns the Options that the command is prepared to handle.
      * If the user provides unknown or malformed arguments, this command will
      * not be invoked.
      */
-    public Collection<ArgumentSpec> getAcceptedArguments();
+    public Options getOptions();
 
     public boolean isStorageRequired();
 
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/HostVMArguments.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/common/core/src/main/java/com/redhat/thermostat/common/cli/HostVMArguments.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,8 +36,8 @@
 
 package com.redhat.thermostat.common.cli;
 
-import java.util.Arrays;
-import java.util.Collection;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -95,25 +95,33 @@
      * @return a collection of arguments for accepting hosts and vms (where both
      * are required)
      */
-    public static Collection<ArgumentSpec> getArgumentSpecs() {
-        return getArgumentSpecs(true);
+    public static Options getOptions() {
+        return getOptions(true);
     }
 
     /**
      * @return a collection of arguments for accepting hosts and vms (where the
      * vm is optional)
      */
-    public static Collection<ArgumentSpec> getArgumentSpecs(boolean vmRequired) {
-        return getArgumentSpecs(true, vmRequired);
+    public static Options getOptions(boolean vmRequired) {
+        return getOptions(true, vmRequired);
     }
 
     /**
-     * @return a collection of arguments for accepting hosts and vms (where the
+     * @return an Options for accepting hosts and vms (where the
      * vm is optional)
      */
-    public static Collection<ArgumentSpec> getArgumentSpecs(boolean hostRequired, boolean vmRequired) {
-        ArgumentSpec vmId = new SimpleArgumentSpec(VM_ID_ARGUMENT, "the ID of the VM to monitor", vmRequired, true);
-        ArgumentSpec hostId = new SimpleArgumentSpec(HOST_ID_ARGUMENT, "the ID of the host to monitor", hostRequired, true);
-        return Arrays.asList(vmId, hostId);
+    public static Options getOptions(boolean hostRequired, boolean vmRequired) {
+        Options options = new Options();
+
+        Option vmIdOption = new Option("p", VM_ID_ARGUMENT, true, "the ID of the VM to monitor");
+        vmIdOption.setRequired(vmRequired);
+        options.addOption(vmIdOption);
+
+        Option hostIdOption = new Option("a", HOST_ID_ARGUMENT, true, "the ID of the host to monitor");
+        hostIdOption.setRequired(hostRequired);
+        options.addOption(hostIdOption);
+
+        return options;
     }
 }
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/SimpleArgumentSpec.java	Tue Oct 02 17:37:10 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.cli;
-
-import java.util.Objects;
-
-public class SimpleArgumentSpec implements ArgumentSpec {
-
-    private String name;
-    private String description;
-    private boolean required;
-    private boolean usingAddionalArgument;
-    private String shortOption;
-
-    public SimpleArgumentSpec() {
-        this(null, null);
-    }
-
-    public SimpleArgumentSpec(String name, String description) {
-        this(name, description, false, false);
-    }
-
-    public SimpleArgumentSpec(String name, String description, boolean required, boolean usingAdditionalArgument) {
-        this(name, null, description, required, usingAdditionalArgument);
-    }
-
-    public SimpleArgumentSpec(String name, String shortOption, String description, boolean required, boolean usingAdditionalArgument) {
-        this.name = name;
-        this.shortOption = shortOption;
-        this.description = description;
-        this.required = required;
-        this.usingAddionalArgument = usingAdditionalArgument;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    void setName(String name) {
-        this.name = name;
-    }
-
-    @Override
-    public String getShortOption() {
-        return shortOption;
-    }
-
-    void setShortOption(String shortOption) {
-        this.shortOption = shortOption;
-    }
-
-    @Override
-    public boolean isRequired() {
-        return required;
-    }
-
-    public void setRequired(boolean required) {
-        this.required = required;
-    }
-
-    @Override
-    public boolean isUsingAdditionalArgument() {
-        return usingAddionalArgument;
-    }
-
-    public void setUsingAdditionalArgument(boolean usingAddionalArgument) {
-        this.usingAddionalArgument = usingAddionalArgument;
-    }
-
-    @Override
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public boolean equals(Object o) {
-        if (! (o instanceof SimpleArgumentSpec)) {
-            return false;
-        }
-        SimpleArgumentSpec other = (SimpleArgumentSpec) o;
-        return Objects.equals(name, other.name)
-                && Objects.equals(description, other.description)
-                && usingAddionalArgument == other.usingAddionalArgument
-                && required == other.required
-                && Objects.equals(shortOption, other.shortOption);
-    }
-
-    public int hashCode() {
-        return Objects.hash(name, description, shortOption, usingAddionalArgument, required);
-    }
-
-}
--- a/common/core/src/test/java/com/redhat/thermostat/common/cli/HostVMArgumentsTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/common/core/src/test/java/com/redhat/thermostat/common/cli/HostVMArgumentsTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,27 +38,25 @@
 
 import static org.junit.Assert.assertEquals;
 
-import java.util.ArrayList;
-
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.HostVMArguments;
 
 public class HostVMArgumentsTest {
 
     @Test
     public void testArgumentSpecification() {
-        ArrayList<ArgumentSpec> args = new ArrayList<>(HostVMArguments.getArgumentSpecs(false));
-        assertEquals(2, args.size());
+        Options options = HostVMArguments.getOptions(false);
+        assertEquals(2, options.getOptions().size());
 
-        // TODO different order should be okay
-        ArgumentSpec vmIdArg = args.get(0);
-        assertEquals("vmId", vmIdArg.getName());
-        assertEquals(false, vmIdArg.isRequired());
+        Option vmIdOption = options.getOption("vmId");
+        assertEquals("vmId", vmIdOption.getLongOpt());
+        assertEquals(false, vmIdOption.isRequired());
 
-        ArgumentSpec hostIdArg = args.get(1);
-        assertEquals("hostId", hostIdArg.getName());
-        assertEquals(true, hostIdArg.isRequired());
+        Option hostIdOption = options.getOption("hostId");
+        assertEquals("hostId", hostIdOption.getLongOpt());
+        assertEquals(true, hostIdOption.isRequired());
     }
 }
--- a/common/core/src/test/java/com/redhat/thermostat/common/cli/SimpleArgumentSpecTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.cli;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SimpleArgumentSpecTest {
-
-    private SimpleArgumentSpec spec;
-    private SimpleArgumentSpec other;
-
-    @Before
-    public void setUp() {
-        spec = new SimpleArgumentSpec();
-        other = new SimpleArgumentSpec();
-    }
-
-    @After
-    public void tearDown() {
-        spec = null;
-        other = null;
-    }
-
-    @Test
-    public void testName() {
-        spec.setName("test1");
-        assertEquals("test1", spec.getName());
-        spec.setName("test2");
-        assertEquals("test2", spec.getName());
-    }
-
-    @Test
-    public void testDescription() {
-        spec.setDescription("test1");
-        assertEquals("test1", spec.getDescription());
-        spec.setDescription("test2");
-        assertEquals("test2", spec.getDescription());
-    }
-
-    @Test
-    public void testRequired() {
-        spec.setRequired(true);
-        assertTrue(spec.isRequired());
-        spec.setRequired(false);
-        assertFalse(spec.isRequired());
-    }
-
-    @Test
-    public void testUsesAdditionalArgument() {
-        spec.setUsingAdditionalArgument(true);
-        assertTrue(spec.isUsingAdditionalArgument());
-        spec.setUsingAdditionalArgument(false);
-        assertFalse(spec.isUsingAdditionalArgument());
-    }
-
-    @Test
-    public void testShortOption() {
-        spec.setShortOption("test1");
-        assertEquals("test1", spec.getShortOption());
-        spec.setShortOption("test2");
-        assertEquals("test2", spec.getShortOption());
-    }
-
-    @Test
-    public void testEquals() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        assertTrue(spec.equals(other));
-    }
-
-    @Test
-    public void testEqualsUnequalName() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        other.setName("fluff");
-
-        assertFalse(spec.equals(other));
-    }
-
-    @Test
-    public void testEqualsUnequalDescription() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        other.setDescription("fluff");
-
-        assertFalse(spec.equals(other));
-    }
-
-    @Test
-    public void testEqualsUnequalUsingAdditionalArgument() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        other.setUsingAdditionalArgument(false);
-
-        assertFalse(spec.equals(other));
-    }
-
-    @Test
-    public void testEqualsUnequalRequired() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        other.setRequired(false);
-
-        assertFalse(spec.equals(other));
-    }
-
-    @Test
-    public void testEqualsUnequalShortOption() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        other.setShortOption("fluff");
-
-        assertFalse(spec.equals(other));
-    }
-
-    @Test
-    public void testEqualsNull() {
-        prepareSpecForEqualsTest(spec);
-
-        assertFalse(spec.equals(null));
-    }
-
-    @Test
-    public void testHashCode() {
-        prepareSpecForEqualsTest(spec);
-        prepareSpecForEqualsTest(other);
-
-        assertEquals(spec.hashCode(), other.hashCode());
-    }
-
-    private void prepareSpecForEqualsTest(SimpleArgumentSpec spec) {
-        spec.setName("test");
-        spec.setDescription("description");
-        spec.setUsingAdditionalArgument(true);
-        spec.setRequired(true);
-        spec.setShortOption("shortOption");
-    }
-}
--- a/common/core/src/test/java/com/redhat/thermostat/common/tools/BasicCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/common/core/src/test/java/com/redhat/thermostat/common/tools/BasicCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,13 +38,11 @@
 
 import static org.junit.Assert.assertNotNull;
 
-import java.util.Collection;
-
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.config.StartupConfiguration;
@@ -84,8 +82,8 @@
             }
 
             @Override
-            public Collection<ArgumentSpec> getAcceptedArguments() {
-                return null;
+            public Options getOptions() {
+                return new Options();
             }
 
             @Override
--- a/common/test/src/main/java/com/redhat/thermostat/test/cli/TestCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/common/test/src/main/java/com/redhat/thermostat/test/cli/TestCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,12 +36,9 @@
 
 package com.redhat.thermostat.test.cli;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -57,7 +54,7 @@
     private boolean availableInShell = true;
     private boolean availableOutsideShell = true;
 
-    private List<ArgumentSpec> arguments = new LinkedList<ArgumentSpec>();
+    private Options options = new Options();
 
     public static interface Handle {
         public void run(CommandContext ctx) throws CommandException;
@@ -103,12 +100,14 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return arguments;
+    public Options getOptions() {
+        return options;
     }
 
-    public void addArguments(ArgumentSpec... arguments) {
-        this.arguments.addAll(Arrays.asList(arguments));
+    public void addOptions(Option... options) {
+        for (Option option : options) {
+            this.options.addOption(option);
+        }
     }
 
     @Override
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/CommonCommandOptions.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/CommonCommandOptions.java	Tue Oct 02 17:43:25 2012 -0400
@@ -1,12 +1,10 @@
 
 package com.redhat.thermostat.launcher;
 
-import java.util.ArrayList;
-import java.util.Collection;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Command;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 
 public class CommonCommandOptions {
 
@@ -21,29 +19,37 @@
     public static final String LOG_LEVEL_ARG = "logLevel";
     private static final String LOG_LEVEL_DESC = "log level";
 
-    public Collection<ArgumentSpec> getAcceptedOptionsFor(Command cmd) {
+    public Options getOptionsFor(Command cmd) {
 
-        Collection<ArgumentSpec> acceptedArguments = cmd.getAcceptedArguments();
-        acceptedArguments = new ArrayList<>(acceptedArguments);
-        addDbUrlOptionForStorageCommand(cmd, acceptedArguments);
-        addLogLevelOption(acceptedArguments);
-        addOptionalAuthenticationArguments(acceptedArguments);
-        return acceptedArguments;
+        Options options = cmd.getOptions();
+        addDbUrlOptionForStorageCommand(cmd, options);
+        addLogLevelOption(options);
+        addOptionalAuthenticationArguments(options);
+        return options;
     }
 
-    private void addDbUrlOptionForStorageCommand(Command cmd, Collection<ArgumentSpec> acceptedArguments) {
+    private void addDbUrlOptionForStorageCommand(Command cmd, Options options) {
         if (cmd.isStorageRequired()) {
-            acceptedArguments.add(new SimpleArgumentSpec(DB_URL_ARG, "d", DB_URL_DESC, false, true));
+            Option option = new Option("d", DB_URL_ARG, true, DB_URL_DESC);
+            option.setRequired(false);
+            options.addOption(option);
         }
     }
 
-    private void addLogLevelOption(Collection<ArgumentSpec> acceptedArguments) {
-        acceptedArguments.add(new SimpleArgumentSpec(LOG_LEVEL_ARG, LOG_LEVEL_DESC, false, true));
+    private void addLogLevelOption(Options options) {
+        Option option = new Option(null, LOG_LEVEL_ARG, true, LOG_LEVEL_DESC);
+        option.setRequired(false);
+        options.addOption(option);
     }
 
-    private void addOptionalAuthenticationArguments(Collection<ArgumentSpec> acceptedArguments) {
-        acceptedArguments.add(new SimpleArgumentSpec(USERNAME_ARG, USERNAME_DESC, false, true));
-        acceptedArguments.add(new SimpleArgumentSpec(PASSWORD_ARG, PASSWORD_DESC, false, true));
+    private void addOptionalAuthenticationArguments(Options options) {
+
+        Option userOption = new Option(null, USERNAME_ARG, true, USERNAME_DESC);
+        userOption.setRequired(false);
+        options.addOption(userOption);
+        Option passwordOption = new Option(null, PASSWORD_ARG, true, PASSWORD_DESC);
+        passwordOption.setRequired(false);
+        options.addOption(passwordOption);
     }
 
 }
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/CommandLineArgumentsParser.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/CommandLineArgumentsParser.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,32 +38,31 @@
 
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.GnuParser;
 import org.apache.commons.cli.MissingOptionException;
+import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 
-import static com.redhat.thermostat.launcher.internal.LaunchUtils.convertToCommonsCLIOptions;
-
 public class CommandLineArgumentsParser {
 
-    private List<ArgumentSpec> arguments = new LinkedList<>();
+    private Options options = new Options();
 
-    void addArguments(Collection<ArgumentSpec> args) {
-        arguments.addAll(args);
+    @SuppressWarnings("unchecked")
+    void addOptions(Options options) {
+        for (Option option : (Collection<Option>) options.getOptions()) {
+            this.options.addOption(option);
+        }
     }
 
     Arguments parse(String[] args) throws CommandLineArgumentParseException {
         try {
-            Options options = convertToCommonsCLIOptions(arguments);
             CommandLineParser parser = new GnuParser();
             CommandLine commandLine;
             commandLine = parser.parse(options, args);
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/HelpCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/HelpCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -46,7 +46,6 @@
 import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Options;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandContext;
@@ -55,8 +54,6 @@
 import com.redhat.thermostat.common.cli.TableRenderer;
 import com.redhat.thermostat.launcher.CommonCommandOptions;
 
-import static com.redhat.thermostat.launcher.internal.LaunchUtils.convertToCommonsCLIOptions;
-
 public class HelpCommand extends SimpleCommand {
 
     private static final int COMMANDS_COLUMNS_WIDTH = 14;
@@ -111,8 +108,7 @@
         HelpFormatter helpFormatter = new HelpFormatter();
         PrintWriter pw = new PrintWriter(ctx.getConsole().getOutput());
         CommonCommandOptions commonOpts = new CommonCommandOptions();
-        Collection<ArgumentSpec> acceptedOptions = commonOpts.getAcceptedOptionsFor(cmd);
-        Options options = convertToCommonsCLIOptions(acceptedOptions);
+        Options options = commonOpts.getOptionsFor(cmd);
         helpFormatter.printHelp(pw, 80, cmd.getName(), cmd.getUsage(), options, 2, 4, null, true);
         pw.flush();
     }
@@ -133,8 +129,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return Collections.emptyList();
+    public Options getOptions() {
+        return new Options();
     }
 
     @Override
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LaunchUtils.java	Tue Oct 02 17:37:10 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.launcher.internal;
-
-import java.util.Collection;
-
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import com.redhat.thermostat.common.cli.ArgumentSpec;
-
-public class LaunchUtils {
-
-    private LaunchUtils() {
-        // do not instantiate.
-    }
-
-    public static Options convertToCommonsCLIOptions(Collection<ArgumentSpec> args) {
-        Options options = new Options();
-        for (ArgumentSpec spec : args) {
-            options.addOption(convertSpecToOption(spec));
-        }
-        return options;
-    }
-
-    private static Option convertSpecToOption(ArgumentSpec spec) {
-        String shortOpt = spec.getShortOption();
-        String longOpt = spec.getName();
-        Option option = new Option(shortOpt, longOpt, spec.isUsingAdditionalArgument(), spec.getDescription());
-        option.setRequired(spec.isRequired());
-        return option;
-    }
-}
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java	Tue Oct 02 17:43:25 2012 -0400
@@ -43,6 +43,7 @@
 import java.util.concurrent.Semaphore;
 import java.util.logging.Level;
 
+import org.apache.commons.cli.Options;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceRegistration;
@@ -53,7 +54,6 @@
 import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandContext;
@@ -217,8 +217,8 @@
             }
         }
         CommonCommandOptions commonOpts = new CommonCommandOptions();
-        Collection<ArgumentSpec> acceptedOptions = commonOpts.getAcceptedOptionsFor(cmd);
-        Arguments args = parseCommandArguments(cmdArgs, acceptedOptions);
+        Options options = commonOpts.getOptionsFor(cmd);
+        Arguments args = parseCommandArguments(cmdArgs, options);
         setupLogLevel(args);
         CommandContext ctx = setupCommandContext(cmd, args);
         cmd.run(ctx);
@@ -247,11 +247,11 @@
         return cmd;
     }
 
-    private Arguments parseCommandArguments(String[] cmdArgs, Collection<ArgumentSpec> acceptedArguments)
+    private Arguments parseCommandArguments(String[] cmdArgs, Options options)
             throws CommandLineArgumentParseException {
 
         CommandLineArgumentsParser cliArgsParser = new CommandLineArgumentsParser();
-        cliArgsParser.addArguments(acceptedArguments);
+        cliArgsParser.addOptions(options);
         Arguments args = cliArgsParser.parse(cmdArgs);
         return args;
     }
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/CommonCommandOptionsTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/test/java/com/redhat/thermostat/launcher/CommonCommandOptionsTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,14 +36,14 @@
 
 package com.redhat.thermostat.launcher;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import java.util.Collection;
-
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.test.cli.TestCommand;
 
 public class CommonCommandOptionsTest {
@@ -54,9 +54,14 @@
         cmd.setStorageRequired(true);
 
         CommonCommandOptions commonOpts = new CommonCommandOptions();
-        Collection<ArgumentSpec> cmdOpts = commonOpts.getAcceptedOptionsFor(cmd);
+        Options cmdOpts = commonOpts.getOptionsFor(cmd);
 
-        assertTrue(cmdOpts.contains(new SimpleArgumentSpec("dbUrl", "d", "the URL of the storage to connect to", false, true)));
+        assertTrue(cmdOpts.hasOption("dbUrl"));
+        Option db = cmdOpts.getOption("dbUrl");
+        assertEquals("d", db.getOpt());
+        assertEquals("the URL of the storage to connect to", db.getDescription());
+        assertFalse(db.isRequired());
+        assertTrue(db.hasArg());
     }
 
     @Test
@@ -64,8 +69,12 @@
         TestCommand cmd = new TestCommand("test1");
 
         CommonCommandOptions commonOpts = new CommonCommandOptions();
-        Collection<ArgumentSpec> cmdOpts = commonOpts.getAcceptedOptionsFor(cmd);
+        Options cmdOpts = commonOpts.getOptionsFor(cmd);
 
-        assertTrue(cmdOpts.contains(new SimpleArgumentSpec("logLevel", "log level", false, true)));
+        assertTrue(cmdOpts.hasOption("logLevel"));
+        Option log = cmdOpts.getOption("logLevel");
+        assertEquals("log level", log.getDescription());
+        assertFalse(log.isRequired());
+        assertTrue(log.hasArg());
     }
 }
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/LauncherTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/test/java/com/redhat/thermostat/launcher/LauncherTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -50,6 +50,8 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -74,7 +76,6 @@
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.config.ClientPreferences;
 import com.redhat.thermostat.common.locale.LocaleResources;
 import com.redhat.thermostat.common.locale.Translate;
@@ -139,18 +140,14 @@
         setupCommandContextFactory();
 
         TestCommand cmd1 = new TestCommand("test1", new TestCmd1());
-        SimpleArgumentSpec arg1 = new SimpleArgumentSpec("arg1", null);
-        arg1.setUsingAdditionalArgument(true);
-        SimpleArgumentSpec arg2 = new SimpleArgumentSpec("arg2", null);
-        arg2.setUsingAdditionalArgument(true);
-        cmd1.addArguments(arg1, arg2);
+        Option opt1 = new Option(null, "arg1", true, null);
+        Option opt2 = new Option(null, "arg2", true, null);
+        cmd1.addOptions(opt1, opt2);
         cmd1.setDescription("description 1");
         TestCommand cmd2 = new TestCommand("test2", new TestCmd2());
-        SimpleArgumentSpec arg3 = new SimpleArgumentSpec("arg3", null);
-        arg3.setUsingAdditionalArgument(true);
-        SimpleArgumentSpec arg4 = new SimpleArgumentSpec("arg4", null);
-        arg4.setUsingAdditionalArgument(true);
-        cmd2.addArguments(arg3, arg4);
+        Option opt3 = new Option(null, "arg3", true, null);
+        Option opt4 = new Option(null, "arg4", true, null);
+        cmd2.addOptions(opt3, opt4);
         cmd2.setDescription("description 2");
 
         TestCommand cmd3 = new TestCommand("test3");
@@ -161,6 +158,8 @@
         when(basicCmd.getName()).thenReturn("basic");
         when(basicCmd.getDescription()).thenReturn("nothing that means anything");
         when(basicCmd.isStorageRequired()).thenReturn(false);
+        Options options = new Options();
+        when(basicCmd.getOptions()).thenReturn(options);
         notifier = mock(ActionNotifier.class);
         when(basicCmd.getNotifier()).thenReturn(notifier);
 
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/CommandLineArgumentsParserTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/CommandLineArgumentsParserTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -39,49 +39,46 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import java.util.Arrays;
-
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.Arguments;
 
 public class CommandLineArgumentsParserTest {
 
     private CommandLineArgumentsParser parser;
 
-    private ArgumentSpec arg3;
-
     @Before
     public void setUp() {
         parser = new CommandLineArgumentsParser();
 
-        ArgumentSpec arg1 = mock(ArgumentSpec.class);
-        when(arg1.getName()).thenReturn("test1");
-        when(arg1.getShortOption()).thenReturn("t");
-        when(arg1.isRequired()).thenReturn(true);
+        Options options = new Options();
+
+        Option option1 = new Option("t", "test1", false, null);
+        option1.setArgName("test1");
+        option1.setRequired(true);
+        options.addOption(option1);
 
-        ArgumentSpec arg2 = mock(ArgumentSpec.class);
-        when(arg2.getName()).thenReturn("test2");
-        when(arg2.isRequired()).thenReturn(false);
+        Option option2 = new Option("r", "test2", false, null);
+        option2.setArgName("test2");
+        option2.setRequired(false);
+        options.addOption(option2);
 
-        arg3 = mock(ArgumentSpec.class);
-        when(arg3.getName()).thenReturn("test3");
-        when(arg3.isRequired()).thenReturn(false);
-        when(arg3.isUsingAdditionalArgument()).thenReturn(true);
+        Option option3 = new Option("s", "test3", true, null);
+        option3.setArgName("test3");
+        option3.setRequired(false);
+        options.addOption(option3);
 
-        parser.addArguments(Arrays.asList(arg1, arg2, arg3));
+        parser.addOptions(options);
     }
 
     @After
     public void tearDown() {
-       parser = null; 
-       arg3 = null;
+       parser = null;
     }
 
     @Test
@@ -123,10 +120,12 @@
 
     @Test
     public void testMissingRequiredArguments() throws CommandLineArgumentParseException {
-        ArgumentSpec arg4 = mock(ArgumentSpec.class);
-        when(arg4.getName()).thenReturn("test4");
-        when(arg4.isRequired()).thenReturn(true);
-        parser.addArguments(Arrays.asList(arg4));
+        Options options = new Options();
+        Option option4 = new Option(null, "test4", false, null);
+        option4.setArgName("test4");
+        option4.setRequired(true);
+        options.addOption(option4);
+        parser.addOptions(options);
 
         try {
           parser.parse(new String[] { "--test2" });
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/ConnectCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/ConnectCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,16 +36,12 @@
 
 package com.redhat.thermostat.tools.cli;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.osgi.framework.ServiceRegistration;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.config.ClientPreferences;
 import com.redhat.thermostat.common.storage.ConnectionException;
@@ -116,12 +112,22 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        List<ArgumentSpec> acceptedArgs = new ArrayList<>();
-        acceptedArgs.add(new SimpleArgumentSpec(CommonCommandOptions.DB_URL_ARG, "d", CommonCommandOptions.DB_URL_DESC, true, true));
-        acceptedArgs.add(new SimpleArgumentSpec(CommonCommandOptions.USERNAME_ARG, "u", CommonCommandOptions.USERNAME_DESC, false, true));
-        acceptedArgs.add(new SimpleArgumentSpec(CommonCommandOptions.PASSWORD_ARG, "p", CommonCommandOptions.PASSWORD_DESC, false, true));
-        return acceptedArgs;
+    public Options getOptions() {
+        Options options = new Options();
+
+        Option dbOption = new Option("d", CommonCommandOptions.DB_URL_ARG, true, CommonCommandOptions.DB_URL_DESC);
+        dbOption.setRequired(true);
+        options.addOption(dbOption);
+
+        Option usernameOption = new Option("u", CommonCommandOptions.USERNAME_ARG, true, CommonCommandOptions.USERNAME_DESC);
+        usernameOption.setRequired(false);
+        options.addOption(usernameOption);
+
+        Option passwordOption = new Option("p", CommonCommandOptions.PASSWORD_ARG, true, CommonCommandOptions.PASSWORD_DESC);
+        passwordOption.setRequired(false);
+        options.addOption(passwordOption);
+
+        return options;
     }
     
     @Override
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/DisconnectCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/DisconnectCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -36,12 +36,9 @@
 
 package com.redhat.thermostat.tools.cli;
 
-import java.util.Collection;
-import java.util.Collections;
-
+import org.apache.commons.cli.Options;
 import org.osgi.framework.ServiceRegistration;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleCommand;
@@ -92,8 +89,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return Collections.emptyList();
+    public Options getOptions() {
+        return new Options();
     }
     
     @Override
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/ListVMsCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/ListVMsCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,10 +37,10 @@
 package com.redhat.thermostat.tools.cli;
 
 import java.util.Collection;
-import java.util.Collections;
+
+import org.apache.commons.cli.Options;
 
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleCommand;
@@ -95,8 +95,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return Collections.emptyList();
+    public Options getOptions() {
+        return new Options();
     }
 
 }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/ShellCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/ShellCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -39,8 +39,6 @@
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -51,10 +49,10 @@
 import jline.console.history.History;
 import jline.console.history.PersistentHistory;
 
+import org.apache.commons.cli.Options;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.OSGiContext;
@@ -80,7 +78,7 @@
 
     private static final String PROMPT = "Thermostat > ";
 
-    private CommandContext context;
+    //private CommandContext context;
     private HistoryProvider historyProvider;
 
     private BundleContext bundleContext;
@@ -112,7 +110,6 @@
     
     @Override
     public void run(CommandContext ctx) throws CommandException {
-        context = ctx;
         Terminal term = TerminalFactory.create();
         PersistentHistory history = historyProvider.get();
 
@@ -192,8 +189,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return Collections.emptyList();
+    public Options getOptions() {
+        return new Options();
     }
 
     @Override
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/VMInfoCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/VMInfoCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -40,8 +40,9 @@
 import java.util.Collection;
 import java.util.Date;
 
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.HostVMArguments;
@@ -127,8 +128,8 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        return HostVMArguments.getArgumentSpecs(false);
+    public Options getOptions() {
+        return HostVMArguments.getOptions(false);
     }
 
 }
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,21 +37,19 @@
 package com.redhat.thermostat.tools.cli;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.HostVMArguments;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleCommand;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
@@ -135,11 +133,14 @@
     }
 
     @Override
-    public Collection<ArgumentSpec> getAcceptedArguments() {
-        List<ArgumentSpec> acceptedArgs = new ArrayList<>(); 
-        acceptedArgs.addAll(HostVMArguments.getArgumentSpecs());
-        acceptedArgs.add(new SimpleArgumentSpec("continuous", "c", Translate.localize(LocaleResources.COMMAND_VM_STAT_ARGUMENT_CONTINUOUS_DESCRIPTION), false, false));
-        return acceptedArgs;
+    public Options getOptions() {
+        Options options = HostVMArguments.getOptions();
+
+        Option continuousOption = new Option("c", "continuous", false, Translate.localize(LocaleResources.COMMAND_VM_STAT_ARGUMENT_CONTINUOUS_DESCRIPTION));
+        continuousOption.setRequired(false);
+        options.addOption(continuousOption);
+
+        return options;
     }
 
 }
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -46,8 +46,8 @@
 import static org.mockito.Mockito.when;
 import static org.mockito.Matchers.any;
 
-import java.util.Collection;
-
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,10 +60,8 @@
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.utils.OSGIUtils;
 import com.redhat.thermostat.launcher.CommonCommandOptions;
@@ -178,11 +176,26 @@
 
     @Test
     public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertNotNull(args);
-        assertTrue(args.size() == 3);
-        assertTrue(args.contains(new SimpleArgumentSpec(CommonCommandOptions.DB_URL_ARG, "d", CommonCommandOptions.DB_URL_DESC, true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec(CommonCommandOptions.USERNAME_ARG, "u", CommonCommandOptions.USERNAME_DESC, false, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec(CommonCommandOptions.PASSWORD_ARG, "p", CommonCommandOptions.PASSWORD_DESC, false, true)));
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertTrue(options.getOptions().size() == 3);
+
+        assertTrue(options.hasOption(CommonCommandOptions.DB_URL_ARG));
+        Option db = options.getOption(CommonCommandOptions.DB_URL_ARG);
+        assertEquals(CommonCommandOptions.DB_URL_DESC, db.getDescription());
+        assertTrue(db.isRequired());
+        assertTrue(db.hasArg());
+
+        assertTrue(options.hasOption(CommonCommandOptions.USERNAME_ARG));
+        Option user = options.getOption(CommonCommandOptions.USERNAME_ARG);
+        assertEquals(CommonCommandOptions.USERNAME_DESC, user.getDescription());
+        assertFalse(user.isRequired());
+        assertTrue(user.hasArg());
+
+        assertTrue(options.hasOption(CommonCommandOptions.PASSWORD_ARG));
+        Option pass = options.getOption(CommonCommandOptions.PASSWORD_ARG);
+        assertEquals(CommonCommandOptions.PASSWORD_DESC, pass.getDescription());
+        assertFalse(pass.isRequired());
+        assertTrue(pass.hasArg());
     }
 }
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -45,8 +45,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.util.Collection;
-
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,7 +59,6 @@
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
@@ -165,9 +163,9 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertNotNull(args);
-        assertTrue(args.size() == 0);
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertTrue(options.getOptions().size() == 0);
     }
 }
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ListVMsCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ListVMsCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,22 +38,20 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
@@ -175,9 +173,9 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertNotNull(args);
-        assertTrue(args.isEmpty());
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertEquals(0, options.getOptions().size());
     }
 }
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ShellCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ShellCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -38,12 +38,12 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.util.Collections;
 
 import jline.TerminalFactory;
 import jline.TerminalFactory.Flavor;
@@ -51,6 +51,7 @@
 import jline.UnixTerminal;
 import jline.console.history.PersistentHistory;
 
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -243,8 +244,10 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        assertEquals(Collections.EMPTY_LIST, cmd.getAcceptedArguments());
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertEquals(0, options.getOptions().size());
     }
 
     @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -37,6 +37,7 @@
 package com.redhat.thermostat.tools.cli;
 
 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.mock;
@@ -45,10 +46,11 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.TimeZone;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -56,9 +58,7 @@
 
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.DAOException;
 import com.redhat.thermostat.common.dao.DAOFactory;
@@ -222,12 +222,22 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertNotNull(args);
-        assertEquals(2, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("vmId", "the ID of the VM to monitor", false, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("hostId", "the ID of the host to monitor", true, true)));
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertEquals(2, options.getOptions().size());
+
+        assertTrue(options.hasOption("vmId"));
+        Option vm = options.getOption("vmId");
+        assertEquals("the ID of the VM to monitor", vm.getDescription());
+        assertFalse(vm.isRequired());
+        assertTrue(vm.hasArg());
+
+        assertTrue(options.hasOption("hostId"));
+        Option host = options.getOption("hostId");
+        assertEquals("the ID of the host to monitor", host.getDescription());
+        assertTrue(host.isRequired());
+        assertTrue(host.hasArg());
     }
 
     @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java	Tue Oct 02 17:37:10 2012 -0400
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java	Tue Oct 02 17:43:25 2012 -0400
@@ -44,13 +44,14 @@
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -60,9 +61,7 @@
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
-import com.redhat.thermostat.common.cli.ArgumentSpec;
 import com.redhat.thermostat.common.cli.CommandException;
-import com.redhat.thermostat.common.cli.SimpleArgumentSpec;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -307,13 +306,29 @@
     }
 
     @Test
-    public void testAcceptedArguments() {
-        Collection<ArgumentSpec> args = cmd.getAcceptedArguments();
-        assertNotNull(args);
-        assertEquals(3, args.size());
-        assertTrue(args.contains(new SimpleArgumentSpec("vmId", "the ID of the VM to monitor", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("hostId", "the ID of the host to monitor", true, true)));
-        assertTrue(args.contains(new SimpleArgumentSpec("continuous", "c", "print data continuously", false, false)));
+    public void testOptions() {
+        Options options = cmd.getOptions();
+        assertNotNull(options);
+        assertEquals(3, options.getOptions().size());
+
+        assertTrue(options.hasOption("vmId"));
+        Option vm = options.getOption("vmId");
+        assertEquals("the ID of the VM to monitor", vm.getDescription());
+        assertTrue(vm.isRequired());
+        assertTrue(vm.hasArg());
+
+        assertTrue(options.hasOption("hostId"));
+        Option host = options.getOption("hostId");
+        assertEquals("the ID of the host to monitor", host.getDescription());
+        assertTrue(host.isRequired());
+        assertTrue(host.hasArg());
+
+        assertTrue(options.hasOption("continuous"));
+        Option cont = options.getOption("continuous");
+        assertEquals("c", cont.getOpt());
+        assertEquals("print data continuously", cont.getDescription());
+        assertFalse(cont.isRequired());
+        assertFalse(cont.hasArg());
     }
 
     @Test