mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 08:03:10 +02:00
add add_deprecated_argument
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
"""Utilities for all Let's Encrypt."""
|
"""Utilities for all Let's Encrypt."""
|
||||||
|
import argparse
|
||||||
import collections
|
import collections
|
||||||
import errno
|
import errno
|
||||||
import logging
|
import logging
|
||||||
@@ -255,3 +256,23 @@ def safe_email(email):
|
|||||||
else:
|
else:
|
||||||
logger.warn("Invalid email address: %s.", email)
|
logger.warn("Invalid email address: %s.", email)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def add_deprecated_argument(add_argument, argument_name):
|
||||||
|
"""Adds a deprecated argument with the name argument_name.
|
||||||
|
|
||||||
|
Deprecated arguments are not shown in the help. If they are used on
|
||||||
|
the command line, a warning is shown stating that the argument is
|
||||||
|
deprecated and no other action is taken.
|
||||||
|
|
||||||
|
:param callable add_argument: Function that adds arguments to an
|
||||||
|
argument parser/group.
|
||||||
|
:param str argument_name: Name of deprecated argument.
|
||||||
|
|
||||||
|
"""
|
||||||
|
class ShowWarning(argparse.Action):
|
||||||
|
"""Action to log a warning when an argument is used."""
|
||||||
|
def __call__(self, unused1, unused2, unused3, option_string=None):
|
||||||
|
print "Use of {0} is deprecated".format(option_string)
|
||||||
|
|
||||||
|
add_argument(argument_name, action=ShowWarning, help=argparse.SUPPRESS)
|
||||||
|
|||||||
Reference in New Issue
Block a user