parent
189eb5b883
commit
18c2029fef
@ -10,9 +10,10 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class ArgparseWriter(object):
|
class ArgparseWriter(argparse.HelpFormatter):
|
||||||
"""Analyzes an argparse ArgumentParser for easy generation of help."""
|
"""Analyzes an argparse ArgumentParser for easy generation of help."""
|
||||||
def __init__(self, out=sys.stdout):
|
def __init__(self, out=sys.stdout):
|
||||||
|
super(ArgparseWriter, self).__init__(out)
|
||||||
self.level = 0
|
self.level = 0
|
||||||
self.out = out
|
self.out = out
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ def _write(self, parser, root=True, level=0):
|
|||||||
def action_group(function, actions):
|
def action_group(function, actions):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
arg = fmt._format_action_invocation(action)
|
arg = fmt._format_action_invocation(action)
|
||||||
help = action.help if action.help else ''
|
help = self._expand_help(action) if action.help else ''
|
||||||
function(arg, re.sub('\n', ' ', help))
|
function(arg, re.sub('\n', ' ', help))
|
||||||
|
|
||||||
if root:
|
if root:
|
||||||
|
Loading…
Reference in New Issue
Block a user