-
Notifications
You must be signed in to change notification settings - Fork 124
Recursively set parser.prog #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… the command name and not sys.argv[0]
…ince this is no longer needed
Codecov Report
@@ Coverage Diff @@
## master #796 +/- ##
==========================================
+ Coverage 96.93% 96.97% +0.03%
==========================================
Files 14 14
Lines 3491 3499 +8
==========================================
+ Hits 3384 3393 +9
+ Misses 107 106 -1
Continue to review full report at Codecov.
|
# Conflicts: # CHANGELOG.md
|
|
||
| def with_argparser_and_unknown_args(argparser: argparse.ArgumentParser, *, | ||
| # noinspection PyProtectedMember | ||
| def set_parser_prog(parser: argparse.ArgumentParser, prog: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this utility function be more appropriate in argparse_custom.py or here?
Actually, it begs the question would all of the decorators and associated utility functions belong better in a separate file?
| alias_epilog = ("See also:\n" | ||
| " macro") | ||
| alias_parser = Cmd2ArgumentParser(description=alias_description, epilog=alias_epilog, prog='alias') | ||
| alias_parser = Cmd2ArgumentParser(description=alias_description, epilog=alias_epilog) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice little improvement that provides a better user experience. Thanks for the PR!
It is no longer necessary to set the
progattribute of an argparser with subcommands. cmd2 now automatically sets the prog value of it and all its subparsers so that all usage statements contain the top level command name and not sys.argv[0].