summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-06-15 13:22:34 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-06-17 14:10:24 -0400
commitedd4cb0f5cfb8160f9788a5df9399b2d67a00676 (patch)
tree978ec857554aff2011a1efd6c20555231e81fa22 /cmd2
parent7fecaa703b6c73170df3aa5bffff2abe6ff58e15 (diff)
downloadcmd2-git-edd4cb0f5cfb8160f9788a5df9399b2d67a00676.tar.gz
Fixed handling of argparse's default options group name which was changed in Python 3.10
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/argparse_custom.py9
-rw-r--r--cmd2/utils.py5
2 files changed, 10 insertions, 4 deletions
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py
index 4ba05985..7b72be9f 100644
--- a/cmd2/argparse_custom.py
+++ b/cmd2/argparse_custom.py
@@ -975,7 +975,12 @@ class Cmd2ArgumentParser(argparse.ArgumentParser):
# positionals, optionals and user-defined groups
for action_group in self._action_groups:
- if action_group.title == 'optional arguments':
+ if sys.version_info >= (3, 10):
+ default_options_group = action_group.title == 'options'
+ else:
+ default_options_group = action_group.title == 'optional arguments'
+
+ if default_options_group:
# check if the arguments are required, group accordingly
req_args = []
opt_args = []
@@ -992,7 +997,7 @@ class Cmd2ArgumentParser(argparse.ArgumentParser):
formatter.end_section()
# now display truly optional arguments
- formatter.start_section(action_group.title)
+ formatter.start_section('optional arguments')
formatter.add_text(action_group.description)
formatter.add_arguments(opt_args)
formatter.end_section()
diff --git a/cmd2/utils.py b/cmd2/utils.py
index cbbd1800..fd2898ad 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -131,8 +131,9 @@ class Settable:
validation using str_to_bool(). The val_type function should raise an exception if it fails.
This exception will be caught and printed by Cmd.do_set().
:param description: string describing this setting
- :param settable_object: Object to configure with the set command
- :param settable_attrib_name: Attribute name to be modified. Defaults to `name` if not specified.
+ :param settable_object: object to which the instance attribute belongs (e.g. self)
+ :param settable_attrib_name: name which displays to the user in the output of the set command.
+ Defaults to `name` if not specified.
:param onchange_cb: optional function or method to call when the value of this settable is altered
by the set command. (e.g. onchange_cb=self.debug_changed)