Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement our fancy new --help output #3883

Merged
merged 29 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9648c52
Start reorganising -h output
pde Dec 7, 2016
14c706d
Fix the --debug flag
pde Dec 8, 2016
c1ec028
Explain the insanity
pde Dec 8, 2016
a6b9cf9
Parallalelise nosetests from tox (#3836)
pde Dec 7, 2016
cd4730a
Improve the "certbot certificates" output (#3846)
pde Dec 8, 2016
75845c0
Improvements, tweaks
pde Dec 8, 2016
d62feec
Capitalise on things
pde Dec 9, 2016
f2a83d7
Print the command summary for -h and -h all, but not otherwise
pde Dec 9, 2016
70a68bd
Add a "certificates" help section
pde Dec 8, 2016
5a31ccf
Clean up usage string construction
pde Dec 8, 2016
7e182a5
Merge branch 'fix-debug' into cli-mainhelp-rebased
pde Dec 9, 2016
3b394c7
Greatly improve "certbot -h TOPIC"
pde Dec 9, 2016
249d525
Merge remote-tracking branch 'origin/master' into cli-mainhelp-rebased
pde Dec 9, 2016
72b1c0c
A few more cli formatting tests
pde Dec 9, 2016
886f209
Auto-populate the verb subgroups from the docs
pde Dec 9, 2016
d106f32
Show the new help output
pde Dec 9, 2016
369cc73
Lint, tweak
pde Dec 9, 2016
8f9922e
More lint, and cleanup
pde Dec 9, 2016
e43285a
Infinite lint
pde Dec 9, 2016
25790e8
Add rename to command summary; sort "-h commands" output
pde Dec 10, 2016
7bfb20b
Use fancy string formatting
pde Dec 10, 2016
34cf9c0
More space
pde Dec 10, 2016
bc6949b
Implement --help manage
pde Dec 10, 2016
bad3127
Remove one comma
pde Dec 10, 2016
cffc5c1
Only create weird parser structures if -h is provided :)
pde Dec 10, 2016
ff6449d
Update sample cli out
pde Dec 10, 2016
d05efc2
Lint
pde Dec 11, 2016
4677e40
Revert cli-help.txt to previous release version
pde Dec 13, 2016
593d156
Grammar & style
pde Dec 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions certbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
manage certificates:
certificates Display information about certs you have from Certbot
revoke Revoke a certificate (supply --cert-path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

rename Rename a certificate

manage your account with Let's Encrypt:
register Create a Let's Encrypt ACME account
Expand Down Expand Up @@ -340,7 +341,7 @@ def add_argument(self, *args, **kwargs):
"short": "Revoke a certificate specified with --cert-path",
"opts": "Options for revocation of certs"
}),
("revoke", {
("rename", {
"short": "Change a certificate's name (for management purposes)",
"opts": "Options changing certificate names"
}),
Expand All @@ -366,7 +367,7 @@ def add_argument(self, *args, **kwargs):
}),
("update_symlinks", {
"short": "Recreate symlinks in your /live/ directory",
"opts": ("Recreates cert and key symlinks in {0}, if you changed them by hand, "
"opts": ("Recreates cert and key symlinks in {0}, if you changed them by hand "
"or edited a renewal configuration file".format(
os.path.join(flag_default("config_dir"), "live")))
}),
Expand Down Expand Up @@ -398,7 +399,7 @@ def __init__(self, args, plugins, detect_defaults=False):

# List of topics for which additional help can be provided
HELP_TOPICS = ["all", "security", "paths", "automation", "testing"] + list(self.VERBS)
HELP_TOPICS += self.COMMANDS_TOPICS
HELP_TOPICS += self.COMMANDS_TOPICS + ["manage"]

plugin_names = list(plugins)
self.help_topics = HELP_TOPICS + plugin_names + [None]
Expand Down Expand Up @@ -437,10 +438,9 @@ def _list_subcommands(self):
longest = max(len(v) for v in VERB_HELP_MAP.keys())

text = "The full list of available SUBCOMMANDS is:\n\n"
for verb, props in VERB_HELP:
padding = (longest - len(verb)) + 4
for verb, props in sorted(VERB_HELP):
doc = props.get("short", "")
text += verb + " " * padding + doc + "\n"
text += '{0:<{length}} {1}\n'.format(verb, doc, length=longest)

text += "\nYou can get more help on a specific subcommand with --help SUBCOMMAND\n"
return text
Expand Down Expand Up @@ -683,21 +683,26 @@ def add_deprecated_argument(self, argument_name, num_args):
util.add_deprecated_argument(
self.parser.add_argument, argument_name, num_args)

def add_group(self, topic, **kwargs):
def add_group(self, topic, verbs=(), **kwargs):
"""Create a new argument group.

This method must be called once for every topic, however, calls
to this function are left next to the argument definitions for
clarity.

:param str topic: Name of the new argument group.
:param str verbs: List of subcommands that should be documented as part of
this help group / topic

:returns: The new argument group.
:rtype: `HelpfulArgumentGroup`

"""
if self.visible_topics[topic]:
self.groups[topic] = self.parser.add_argument_group(topic, **kwargs)
if self.help_arg:
for v in verbs:
self.groups[topic].add_argument(v, help=VERB_HELP_MAP[v]["short"])

return HelpfulArgumentGroup(self, topic)

Expand Down Expand Up @@ -738,10 +743,12 @@ def determine_help_topics(self, chosen_topic):
def _add_all_groups(helpful):
helpful.add_group("automation", description="Arguments for automating execution & other tweaks")
helpful.add_group("security", description="Security parameters & server settings")
helpful.add_group(
"testing", description="The following flags are meant for "
"testing and integration purposes only.")
helpful.add_group("testing",
description="The following flags are meant for testing and integration purposes only.")
helpful.add_group("paths", description="Arguments changing execution paths & servers")
helpful.add_group("manage",
description="Various subcommands and flags are available for managing your certificates:",
verbs=["certificates", "renew", "revoke", "rename"])

# VERBS
for verb, docs in VERB_HELP:
Expand Down Expand Up @@ -788,15 +795,15 @@ def prepare_and_parse_args(plugins, args, detect_defaults=False): # pylint: dis
"multiple -d flags or enter a comma separated list of domains "
"as a parameter.")
helpful.add(
[None, "run", "certonly"],
[None, "run", "certonly", "manage"],
"--cert-name", dest="certname",
metavar="CERTNAME", default=None,
help="Certificate name to apply. Only one certificate name can be used "
"per Certbot run. To see certificate names, run 'certbot certificates'."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space after the period

"If there is no existing certificate with this name and "
"domains are requested, create a new certificate with this name.")
helpful.add(
"rename",
["rename", "manage"],
"--updated-cert-name", dest="new_certname",
metavar="NEW_CERTNAME", default=None,
help="New name for the certificate. Must be a valid filename.")
Expand Down Expand Up @@ -1051,9 +1058,7 @@ def _paths_parser(helpful):
verb = helpful.help_arg

cph = "Path to where cert is saved (with auth --csr), installed from or revoked."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a lack of oxford comma I see? Probably because other parts are hogging all the commas.

section = "paths"
if verb in ("install", "revoke", "certonly"):
section = verb
section = ["paths", "install", "revoke", "certonly", "manage"]
if verb == "certonly":
add(section, "--cert-path", type=os.path.abspath,
default=flag_default("auth_cert_path"), help=cph)
Expand Down
22 changes: 17 additions & 5 deletions docs/cli-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ obtain, install, and renew certificates:
manage certificates:
certificates Display information about certs you have from Certbot
revoke Revoke a certificate (supply --cert-path)
rename Rename a certificate

manage your account with Let's Encrypt:
register Create a Let's Encrypt ACME account
Expand Down Expand Up @@ -53,9 +54,6 @@ optional arguments:
certificate with this name and domains are requested,
create a new certificate with this name. (default:
None)
--updated-cert-name NEW_CERTNAME
New name for the certificate. Must be a valid
filename. (default: None)
--dry-run Perform a test run of the client, obtaining test
(invalid) certs but not saving them to disk. This can
currently only be used with the 'certonly' and 'renew'
Expand Down Expand Up @@ -210,6 +208,16 @@ paths:
--server SERVER ACME Directory Resource URI. (default:
https://acme-v01.api.letsencrypt.org/directory)

manage:
Various subcommands and flags are available for managing your
certificates:

certificates List all certificates managed by Certbot
renew Renew all certificates (or one specifed with --cert-
name)
revoke Revoke a certificate specified with --cert-path
rename Change a certificate's name (for management purposes)

run:
Options for obtaining & installing certs

Expand Down Expand Up @@ -268,9 +276,13 @@ certificates:
revoke:
Options for revocation of certs

revoke:
rename:
Options changing certificate names

--updated-cert-name NEW_CERTNAME
New name for the certificate. Must be a valid
filename. (default: None)

register:
Options for account registration & modification

Expand Down Expand Up @@ -322,7 +334,7 @@ plugins:

update_symlinks:
Recreates cert and key symlinks in /etc/letsencrypt/live, if you changed
them by hand, or edited a renewal configuration file
them by hand or edited a renewal configuration file

plugins:
Plugin Selection: Certbot client supports an extensible plugins
Expand Down