[eit.commands.command] move man() from eit.commands.commit to eit.commands.command (rename to _eit())
This commit is contained in:
@@ -33,6 +33,11 @@ class EitCommand(object):
|
||||
# Allow unprivileged access ?
|
||||
ALLOW_UNPRIVILEGED = False
|
||||
|
||||
# These two class variables are used in the man page
|
||||
# generation. You also need to override man()
|
||||
INTRODUCTION = "No introduction available"
|
||||
SEE_ALSO = ""
|
||||
|
||||
def __init__(self, args):
|
||||
self._args = args
|
||||
|
||||
@@ -77,6 +82,60 @@ class EitCommand(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def _man(self):
|
||||
"""
|
||||
Standard man page outcome generator that can be used
|
||||
to implement class-specific man() methods.
|
||||
You need to provide your own INTRODUCTION and
|
||||
SEE_ALSO class fields (see class-level variables).
|
||||
"""
|
||||
parser = self._get_parser()
|
||||
prog = "%s %s" % ("eit", self.NAME)
|
||||
formatter = parser.formatter_class(prog=prog)
|
||||
usage = formatter._format_usage(parser.usage,
|
||||
parser._actions,
|
||||
parser._mutually_exclusive_groups,
|
||||
"").rstrip()
|
||||
|
||||
options_txt = []
|
||||
action_groups = parser._action_groups
|
||||
if action_groups:
|
||||
options_header = "\"eit " + self.NAME + "\" "
|
||||
options_header += "supports the following options which "
|
||||
options_header += "alters its behaviour.\n\n"
|
||||
options_txt.append(options_header)
|
||||
|
||||
for group in action_groups:
|
||||
options_txt.append(group.title.upper())
|
||||
options_txt.append("~" * len(group.title))
|
||||
for action in group._group_actions:
|
||||
action_name = action.metavar
|
||||
|
||||
option_strings = action.option_strings
|
||||
if not option_strings:
|
||||
# positional args
|
||||
action_str = "*" + action_name + "*::\n"
|
||||
action_str += " " + action.help + "\n"
|
||||
else:
|
||||
action_str = ""
|
||||
for option_str in option_strings:
|
||||
action_str = "*" + option_str + "*"
|
||||
if action_name:
|
||||
action_str += "=" + action_name
|
||||
action_str += "::\n"
|
||||
action_str += " " + action.help + "\n"
|
||||
options_txt.append(action_str)
|
||||
|
||||
data = {
|
||||
'name': self.NAME,
|
||||
'description': parser.description,
|
||||
'introduction': self.INTRODUCTION,
|
||||
'seealso': self.SEE_ALSO,
|
||||
'synopsis': usage,
|
||||
'options': "\n".join(options_txt),
|
||||
}
|
||||
return data
|
||||
|
||||
def _entropy(self, *args, **kwargs):
|
||||
"""
|
||||
Return the Entropy Server object.
|
||||
|
||||
@@ -109,52 +109,7 @@ If you would like to selectively add certain packages, please see
|
||||
"""
|
||||
Overridden from EitCommand.
|
||||
"""
|
||||
parser = self._get_parser()
|
||||
prog = "%s %s" % ("eit", self.NAME)
|
||||
formatter = parser.formatter_class(prog=prog)
|
||||
usage = formatter._format_usage(parser.usage,
|
||||
parser._actions,
|
||||
parser._mutually_exclusive_groups,
|
||||
"").rstrip()
|
||||
|
||||
options_txt = []
|
||||
action_groups = parser._action_groups
|
||||
if action_groups:
|
||||
options_header = "\"eit " + self.NAME + "\" "
|
||||
options_header += "supports the following options which "
|
||||
options_header += "alters its behaviour.\n\n"
|
||||
options_txt.append(options_header)
|
||||
|
||||
for group in action_groups:
|
||||
options_txt.append(group.title.upper())
|
||||
options_txt.append("~" * len(group.title))
|
||||
for action in group._group_actions:
|
||||
action_name = action.metavar
|
||||
|
||||
option_strings = action.option_strings
|
||||
if not option_strings:
|
||||
# positional args
|
||||
action_str = "*" + action_name + "*::\n"
|
||||
action_str += " " + action.help + "\n"
|
||||
else:
|
||||
action_str = ""
|
||||
for option_str in option_strings:
|
||||
action_str = "*" + option_str + "*"
|
||||
if action_name:
|
||||
action_str += "=" + action_name
|
||||
action_str += "::\n"
|
||||
action_str += " " + action.help + "\n"
|
||||
options_txt.append(action_str)
|
||||
|
||||
data = {
|
||||
'name': self.NAME,
|
||||
'description': parser.description,
|
||||
'introduction': self.INTRODUCTION,
|
||||
'seealso': self.SEE_ALSO,
|
||||
'synopsis': usage,
|
||||
'options': "\n".join(options_txt),
|
||||
}
|
||||
return data
|
||||
return self._man()
|
||||
|
||||
def parse(self):
|
||||
parser = self._get_parser()
|
||||
|
||||
Reference in New Issue
Block a user