From 0fa307806e1c0220314dcbc378895c49bcb5d64d Mon Sep 17 00:00:00 2001 From: yomna Date: Tue, 17 Jan 2017 15:19:33 -0800 Subject: [PATCH] Alternate help syntax - issue 3371 (#4068) * [#3371] support for new help syntax + tests * [#3371] splitting up test to satisfy linter --- certbot/cli.py | 4 ++++ certbot/tests/cli_test.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/certbot/cli.py b/certbot/cli.py index d51fd58e0..4aeac6d34 100644 --- a/certbot/cli.py +++ b/certbot/cli.py @@ -432,6 +432,10 @@ class HelpfulArgumentParser(object): self.detect_defaults = detect_defaults self.args = args + + if self.args[0] == 'help': + self.args[0] = '--help' + self.determine_verb() help1 = self.prescan_for_flag("-h", self.help_topics) help2 = self.prescan_for_flag("--help", self.help_topics) diff --git a/certbot/tests/cli_test.py b/certbot/tests/cli_test.py index b0eb96542..1fa2004d3 100644 --- a/certbot/tests/cli_test.py +++ b/certbot/tests/cli_test.py @@ -131,6 +131,26 @@ class ParseTest(unittest.TestCase): self.assertTrue("%s" not in out) self.assertTrue("{0}" not in out) + def test_help_no_dashes(self): + self._help_output(['help']) # assert SystemExit is raised here + + out = self._help_output(['help', 'all']) + self.assertTrue("--configurator" in out) + self.assertTrue("how a cert is deployed" in out) + self.assertTrue("--webroot-path" in out) + self.assertTrue("--text" not in out) + self.assertTrue("--dialog" not in out) + self.assertTrue("%s" not in out) + self.assertTrue("{0}" not in out) + + out = self._help_output(['help', 'install']) + self.assertTrue("--cert-path" in out) + self.assertTrue("--key-path" in out) + + out = self._help_output(['help', 'revoke']) + self.assertTrue("--cert-path" in out) + self.assertTrue("--key-path" in out) + def test_parse_domains(self): short_args = ['-d', 'example.com'] namespace = self.parse(short_args)