summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Douchant <Fabrice.Douchant@logilab.fr>2008-10-30 11:18:47 +0100
committerFabrice Douchant <Fabrice.Douchant@logilab.fr>2008-10-30 11:18:47 +0100
commit7564ccf79cd69054bcab0d117182e9b49ce40deb (patch)
treea3a87a860761a77df5956bb8ab81db356509dd72
parentadf3c9846945356098aaa05f893308f5e691a879 (diff)
downloadlogilab-common-7564ccf79cd69054bcab0d117182e9b49ce40deb.tar.gz
[#4910,#6473] now option can have a new key in dictionary : 'hide':True/Fase.
If hide exists and is set at True then the option will not be displayed in man or --help.
-rw-r--r--optik_ext.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/optik_ext.py b/optik_ext.py
index ffaf1ba..3c6dff9 100644
--- a/optik_ext.py
+++ b/optik_ext.py
@@ -29,7 +29,7 @@ try:
# python >= 2.3
from optparse import OptionParser as BaseParser, Option as BaseOption, \
OptionGroup, OptionValueError, OptionError, Values, HelpFormatter, \
- NO_DEFAULT
+ NO_DEFAULT, SUPPRESS_HELP
except ImportError:
# python < 2.3
from optik import OptionParser as BaseParser, Option as BaseOption, \
@@ -153,6 +153,7 @@ class Option(BaseOption):
"""
TYPES = BaseOption.TYPES + ('regexp', 'csv', 'yn', 'named', 'password',
'multiple_choice', 'file', 'font', 'color')
+ ATTRS = BaseOption.ATTRS + ['hide']
TYPE_CHECKER = copy(BaseOption.TYPE_CHECKER)
TYPE_CHECKER['regexp'] = check_regexp
TYPE_CHECKER['csv'] = check_csv
@@ -166,6 +167,11 @@ class Option(BaseOption):
TYPES += ('date',)
TYPE_CHECKER['date'] = check_date
+ def __init__(self, *opts, **attrs):
+ BaseOption.__init__(self, *opts, **attrs)
+ if hasattr(self, "hide") and self.hide:
+ self.help = SUPPRESS_HELP
+
def _check_choice(self):
"""FIXME: need to override this due to optik misdesign"""
if self.type in ("choice", "multiple_choice"):