mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 16:30:31 +02:00
Go back to VERBS as a list
The dictionary was destroying the ordering, which was important.
This commit is contained in:
+12
-16
@@ -730,24 +730,20 @@ def create_parser(plugins, args):
|
||||
return helpful.parser, helpful.args
|
||||
|
||||
# For now unfortunately this constant just needs to match the code below;
|
||||
# there isn't an elegant way to autogenerate it in time. pylint: disable=bad-whitespace
|
||||
VERBS = {
|
||||
"run" : run,
|
||||
"auth" : auth,
|
||||
"install" : install,
|
||||
"revoke" : revoke,
|
||||
"rollback" : rollback,
|
||||
"config_changes" : config_changes,
|
||||
"plugins" : plugins_cmd
|
||||
}
|
||||
HELP_TOPICS = ["all", "security", "paths", "automation", "testing"] + VERBS.keys()
|
||||
# there isn't an elegant way to autogenerate it in time.
|
||||
VERBS = ["run", "auth", "install", "revoke", "rollback", "config_changes", "plugins"]
|
||||
HELP_TOPICS = ["all", "security", "paths", "automation", "testing"] + VERBS
|
||||
|
||||
def _create_subparsers(helpful):
|
||||
subparsers = helpful.parser.add_subparsers(metavar="SUBCOMMAND")
|
||||
|
||||
def add_subparser(name, func): # pylint: disable=missing-docstring
|
||||
subparser = subparsers.add_parser(
|
||||
name, help=func.__doc__.splitlines()[0], description=func.__doc__)
|
||||
def add_subparser(name): # pylint: disable=missing-docstring
|
||||
if name == "plugins":
|
||||
func = plugins_cmd
|
||||
else:
|
||||
func = eval(name) # pylint: disable=eval-used
|
||||
h = func.__doc__.splitlines()[0]
|
||||
subparser = subparsers.add_parser(name, help=h, description=func.__doc__)
|
||||
subparser.set_defaults(func=func)
|
||||
return subparser
|
||||
|
||||
@@ -756,8 +752,8 @@ def _create_subparsers(helpful):
|
||||
# these add_subparser objects return objects to which arguments could be
|
||||
# attached, but they have annoying arg ordering constrains so we use
|
||||
# groups instead: https://github.com/letsencrypt/letsencrypt/issues/820
|
||||
for v, func in VERBS.items():
|
||||
add_subparser(v, func)
|
||||
for v in VERBS:
|
||||
add_subparser(v)
|
||||
|
||||
helpful.add_group("auth", description="Options for modifying how a cert is obtained")
|
||||
helpful.add_group("install", description="Options for modifying how a cert is deployed")
|
||||
|
||||
@@ -44,8 +44,6 @@ class CLITest(unittest.TestCase):
|
||||
|
||||
def test_no_flags(self):
|
||||
with mock.patch('letsencrypt.cli.run') as mock_run:
|
||||
from letsencrypt import cli
|
||||
cli.VERBS["run"] = mock_run
|
||||
self._call([])
|
||||
self.assertEqual(1, mock_run.call_count)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user