-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
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 14c706d
Fix the --debug flag
pde c1ec028
Explain the insanity
pde a6b9cf9
Parallalelise nosetests from tox (#3836)
pde cd4730a
Improve the "certbot certificates" output (#3846)
pde 75845c0
Improvements, tweaks
pde d62feec
Capitalise on things
pde f2a83d7
Print the command summary for -h and -h all, but not otherwise
pde 70a68bd
Add a "certificates" help section
pde 5a31ccf
Clean up usage string construction
pde 7e182a5
Merge branch 'fix-debug' into cli-mainhelp-rebased
pde 3b394c7
Greatly improve "certbot -h TOPIC"
pde 249d525
Merge remote-tracking branch 'origin/master' into cli-mainhelp-rebased
pde 72b1c0c
A few more cli formatting tests
pde 886f209
Auto-populate the verb subgroups from the docs
pde d106f32
Show the new help output
pde 369cc73
Lint, tweak
pde 8f9922e
More lint, and cleanup
pde e43285a
Infinite lint
pde 25790e8
Add rename to command summary; sort "-h commands" output
pde 7bfb20b
Use fancy string formatting
pde 34cf9c0
More space
pde bc6949b
Implement --help manage
pde bad3127
Remove one comma
pde cffc5c1
Only create weird parser structures if -h is provided :)
pde ff6449d
Update sample cli out
pde d05efc2
Lint
pde 4677e40
Revert cli-help.txt to previous release version
pde 593d156
Grammar & style
pde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
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 | ||
|
@@ -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" | ||
}), | ||
|
@@ -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"))) | ||
}), | ||
|
@@ -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] | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
||
|
@@ -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: | ||
|
@@ -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'." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.") | ||
|
@@ -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." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added