Allow filtering of "certbot certificates output" with --config-name or -d

This commit is contained in:
Peter Eckersley 2016-12-20 14:20:35 -08:00
parent e5e5db24d7
commit 03f312e653
2 changed files with 12 additions and 5 deletions

View file

@ -171,6 +171,10 @@ def _report_human_readable(config, parsed_certs):
certinfo = []
checker = ocsp.RevocationChecker(config)
for cert in parsed_certs:
if config.certname and cert.lineagename != config.certname:
continue
if config.domains and not set(config.domains).issubset(cert.names()):
continue
now = pytz.UTC.fromutc(datetime.datetime.utcnow())
status = ""
if cert.is_test_cert:
@ -212,7 +216,8 @@ def _describe_certs(config, parsed_certs, parse_failures):
notify("No certs found.")
else:
if parsed_certs:
notify("Found the following certs:")
match = "matching " if config.certname or config.domains else ""
notify("Found the following {0}certs:".format(match))
notify(_report_human_readable(config, parsed_certs))
if parse_failures:
notify("\nThe following renewal configuration files "

View file

@ -350,8 +350,10 @@ VERB_HELP = [
"usage": "\n\n certbot renew [--cert-name NAME] [options]\n\n"
}),
("certificates", {
"short": "List all certificates managed by Certbot",
"opts": "List all certificates managed by Certbot"
"short": "List certificates managed by Certbot",
"opts": "List certificates managed by Certbot",
"usage": ("\n\n certbot certificates [options] ...\n\n"
"Print information about the status of certificates managed by Certbot.")
}),
("delete", {
"short": "Clean up all files related to a certificate",
@ -824,14 +826,14 @@ def prepare_and_parse_args(plugins, args, detect_defaults=False): # pylint: dis
"being run in a terminal. This flag cannot be used with the "
"renew subcommand.")
helpful.add(
[None, "run", "certonly"],
[None, "run", "certonly", "certificates"],
"-d", "--domains", "--domain", dest="domains",
metavar="DOMAIN", action=_DomainsAction, default=[],
help="Domain names to apply. For multiple domains you can use "
"multiple -d flags or enter a comma separated list of domains "
"as a parameter. (default: Ask)")
helpful.add(
[None, "run", "certonly", "manage", "rename", "delete"],
[None, "run", "certonly", "manage", "rename", "delete", "certificates"],
"--cert-name", dest="certname",
metavar="CERTNAME", default=None,
help="Certificate name to apply. Only one certificate name can be used "