cli/command: Make device argument named by default.

The standard way to build the device argument required it to be
a positional argument. Positional is less flexible and predictable
long term, make it named for future commands.

BUG=chromium:1045508
TEST=run_tests

Change-Id: Iccb02acb1c2a3deb971d32887ebd57fa9055aef0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2057367
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/cli/command_unittest.py b/cli/command_unittest.py
index 1e198af..09a594f 100644
--- a/cli/command_unittest.py
+++ b/cli/command_unittest.py
@@ -60,10 +60,18 @@
   def testAddDeviceArgument(self):
     """Tests CliCommand.AddDeviceArgument()."""
     parser = argparse.ArgumentParser()
-    command.CliCommand.AddDeviceArgument(parser)
+    command.CliCommand.AddDeviceArgument(parser, positional=True)
     # Device should be a positional argument.
     parser.parse_args(['device'])
 
+  def testAddNamedDeviceArgument(self):
+    """Tests CliCommand.AddDeviceArgument()."""
+    parser = argparse.ArgumentParser()
+    command.CliCommand.AddDeviceArgument(parser, positional=False)
+    # Device should be a named argument.
+    parser.parse_args(['--device=device'])
+    parser.parse_args(['-d', 'device'])
+
 
 class MockCommand(partial_mock.PartialMock):
   """Mock class for a generic CLI command."""