aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mchucarr...@apache.org
Subject git commit: Fix errors in help rendering:
Date Thu, 16 Oct 2014 13:07:21 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 797b8152b -> 9534ea303


Fix errors in help rendering:

- Put plugin-generated options into the correct order.
- Include the option-name in the detailed help list.
- Add missing metavars.

Bugs closed: aurora-831

Reviewed at https://reviews.apache.org/r/26688/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/9534ea30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/9534ea30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/9534ea30

Branch: refs/heads/master
Commit: 9534ea30330a954cf806a3f0cc3b52dbe6cbb9ff
Parents: 797b815
Author: Mark Chu-Carroll <mchucarroll@twopensource.com>
Authored: Thu Oct 16 09:04:40 2014 -0400
Committer: Mark Chu-Carroll <mchucarroll@twitter.com>
Committed: Thu Oct 16 09:04:40 2014 -0400

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/__init__.py |  3 ++
 .../python/apache/aurora/client/cli/options.py  |  5 +++-
 .../aurora/client/cli/standalone_client.py      |  4 +--
 .../apache/aurora/client/cli/test_help.py       | 29 ++++++++++++++++++++
 4 files changed, 38 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9534ea30/src/main/python/apache/aurora/client/cli/__init__.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/__init__.py b/src/main/python/apache/aurora/client/cli/__init__.py
index da9d5b6..376106c 100644
--- a/src/main/python/apache/aurora/client/cli/__init__.py
+++ b/src/main/python/apache/aurora/client/cli/__init__.py
@@ -529,7 +529,10 @@ class Verb(AuroraCommand):
     users may want to specify usage themselves.
     """
     result = [self.name]
+    for plugin in self.noun.commandline.plugins:
+      result += ["  " + opt.render_usage() for opt in plugin.get_options()]
     result += [opt.render_usage() for opt in self.get_options()]
+
     return " ".join(result)
 
   @abstractmethod

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9534ea30/src/main/python/apache/aurora/client/cli/options.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/options.py b/src/main/python/apache/aurora/client/cli/options.py
index dc76c25..1f5cbb6 100644
--- a/src/main/python/apache/aurora/client/cli/options.py
+++ b/src/main/python/apache/aurora/client/cli/options.py
@@ -82,7 +82,10 @@ class CommandOption(object):
     elif self.type is None and "choices" in self.kwargs:
       result = "%s=%s" % (self.name, self.kwargs["choices"])
     else:
-      result = "%s" % (self.get_displayname())
+      if self.name.startswith("--"):
+        result = "%s=%s" % (self.name, self.get_displayname())
+      else:
+        result = "%s" % self.get_displayname()
     return [result, "\t" + self.help]
 
   def add_to_parser(self, parser):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9534ea30/src/main/python/apache/aurora/client/cli/standalone_client.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/standalone_client.py b/src/main/python/apache/aurora/client/cli/standalone_client.py
index 20f4d7e..a4b71eb 100644
--- a/src/main/python/apache/aurora/client/cli/standalone_client.py
+++ b/src/main/python/apache/aurora/client/cli/standalone_client.py
@@ -58,8 +58,8 @@ class AuroraLogConfigurationPlugin(ConfigurationPlugin):
         CommandOption("--verbose-logging", "-v", default=False, action="store_true",
           help=("Show verbose logging, including all logs up to level INFO (equivalent to
"
               "--logging-level=20)")),
-        CommandOption("--logging-level", default=None, type=int,
-          help="Set logging to a specific numeric level.")
+        CommandOption("--logging-level", default=None, type=int, metavar="numeric_level",
+          help="Set logging to a specific numeric level, using the standard python log-levels.")
     ]
 
   def before_dispatch(self, raw_args):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9534ea30/src/test/python/apache/aurora/client/cli/test_help.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_help.py b/src/test/python/apache/aurora/client/cli/test_help.py
index f73c8a3..551c9f9 100644
--- a/src/test/python/apache/aurora/client/cli/test_help.py
+++ b/src/test/python/apache/aurora/client/cli/test_help.py
@@ -60,6 +60,35 @@ class TestHelp(unittest.TestCase):
       assert '==Commands for jobs' in self.transcript
       assert '==Commands for quotas' in self.transcript
 
+  def test_usage_string_includes_plugin_options(self):
+    plugin_options = []
+    for plugin in self.cmd.plugins:
+      if plugin.get_options() is not None:
+        plugin_options += [p for p in plugin.get_options()]
+    with patch('apache.aurora.client.cli.client.AuroraCommandLine.print_out',
+        side_effect=self.mock_print):
+      for noun in self.cmd.registered_nouns:
+        for verb in self.cmd.nouns.get(noun).verbs.keys():
+          self.transcript = []
+          self.cmd.execute(['help', noun, verb])
+          for opt in plugin_options:
+            assert any(opt.name in line for line in self.transcript)
+
+  def test_command_help_does_not_have_unset_str_metavars(self):
+    plugin_options = []
+    for plugin in self.cmd.plugins:
+      if plugin.get_options() is not None:
+        plugin_options += [p for p in plugin.get_options()]
+    with patch('apache.aurora.client.cli.client.AuroraCommandLine.print_out',
+               side_effect=self.mock_print):
+      for noun in self.cmd.registered_nouns:
+        for verb in self.cmd.nouns.get(noun).verbs.keys():
+          self.transcript = []
+          self.cmd.execute(['help', noun, verb])
+          print(self.transcript)
+          for opt in plugin_options:
+            assert not any(line.endswith('=str') for line in self.transcript)
+
   def test_help_noun(self):
     with patch('apache.aurora.client.cli.client.AuroraCommandLine.print_out',
         side_effect=self.mock_print):


Mime
View raw message