Skip to content

No longer setting parser's prog value in with_argparser(). #1462

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

Merged
merged 1 commit into from
Jul 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- Breaking Changes

- Removed macros
- No longer setting parser's `prog` value in `with_argparser()` since it gets set in
`Cmd._build_parser()`. This code had previously been restored to support backward
compatibility in `cmd2` 2.0 family.

- Enhancements
- Simplified the process to set a custom parser for `cmd2's` built-in commands. See
Expand Down
8 changes: 0 additions & 8 deletions cmd2/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,6 @@ def cmd_wrapper(*args: Any, **kwargs: dict[str, Any]) -> Optional[bool]:

command_name = func.__name__[len(constants.COMMAND_FUNC_PREFIX) :]

if isinstance(parser, argparse.ArgumentParser):
# Set parser's prog value for backward compatibility within the cmd2 2.0 family.
# This will be removed in cmd2 3.0 since we never reference this parser object's prog value.
# Since it's possible for the same parser object to be passed into multiple with_argparser()
# calls, we only set prog on the deep copies of this parser based on the specific do_xxxx
# instance method they are associated with.
_set_parser_prog(parser, command_name)

# Set some custom attributes for this command
setattr(cmd_wrapper, constants.CMD_ATTR_ARGPARSER, parser)
setattr(cmd_wrapper, constants.CMD_ATTR_PRESERVE_QUOTES, preserve_quotes)
Expand Down
Loading