5050 pass
5151
5252
53+ def print_help (parser ):
54+ """print help for humans"""
55+ print (parser .description )
56+ print ('\n commands:\n ' )
57+
58+ # https://stackoverflow.com/questions/20094215/argparse-subparser-monolithic-help-output
59+ # retrieve subparsers from parser
60+ subparsers_actions = [
61+ action for action in parser ._actions
62+ if isinstance (action , argparse ._SubParsersAction )]
63+ # there will probably only be one subparser_action,
64+ # but better save than sorry
65+ for subparsers_action in subparsers_actions :
66+ # get all subparsers and print help
67+ for choice in subparsers_action ._choices_actions :
68+ print (' {:<19} {}' .format (choice .dest , choice .help ))
69+
5370def main ():
5471 parser = argparse .ArgumentParser (
5572 description = (
56- 'Gitless: a version control system built on top of Git. More info, '
57- 'downloads and documentation available at {0}' .format (URL )),
73+ 'Gitless: a version control system built on top of Git.\n More info, '
74+ 'downloads and documentation at {0}' .format (URL )),
5875 formatter_class = argparse .RawDescriptionHelpFormatter )
5976 parser .add_argument (
6077 '--version' , action = 'version' , version = (
@@ -71,7 +88,7 @@ def main():
7188 sub_cmd .parser (subparsers , repo )
7289
7390 if len (sys .argv ) == 1 :
74- parser . print_help ()
91+ print_help (parser )
7592 return SUCCESS
7693
7794 args = parser .parse_args ()
0 commit comments