Skip to content

Conversation

@kmvanbrunt
Copy link
Member

It is no longer necessary to set the prog attribute 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].

@kmvanbrunt kmvanbrunt requested a review from anselor October 30, 2019 23:05
@kmvanbrunt kmvanbrunt changed the title Set prog Recursively set parser.prog Oct 30, 2019
@codecov
Copy link

codecov bot commented Oct 30, 2019

Codecov Report

Merging #796 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
cmd2/cmd2.py 96.68% <100%> (+0.01%) ⬆️
cmd2/utils.py 97.85% <0%> (+0.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1873c3...5a58199. Read the comment docs.

# Conflicts:
#	CHANGELOG.md

def with_argparser_and_unknown_args(argparser: argparse.ArgumentParser, *,
# noinspection PyProtectedMember
def set_parser_prog(parser: argparse.ArgumentParser, prog: str):
Copy link
Member

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)
Copy link
Member

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!

@tleonhardt tleonhardt merged commit 245dc33 into master Oct 31, 2019
@tleonhardt tleonhardt deleted the set_prog branch October 31, 2019 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants