mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 00:00:44 +02:00
add add_deprecated_argument
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Utilities for all Let's Encrypt."""
|
||||
import argparse
|
||||
import collections
|
||||
import errno
|
||||
import logging
|
||||
@@ -255,3 +256,23 @@ def safe_email(email):
|
||||
else:
|
||||
logger.warn("Invalid email address: %s.", email)
|
||||
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