cmd2 2.6.2__py3-none-any.whl → 2.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cmd2/argparse_custom.py +47 -38
- cmd2/cmd2.py +9 -9
- {cmd2-2.6.2.dist-info → cmd2-2.7.0.dist-info}/METADATA +2 -1
- {cmd2-2.6.2.dist-info → cmd2-2.7.0.dist-info}/RECORD +7 -7
- {cmd2-2.6.2.dist-info → cmd2-2.7.0.dist-info}/WHEEL +0 -0
- {cmd2-2.6.2.dist-info → cmd2-2.7.0.dist-info}/licenses/LICENSE +0 -0
- {cmd2-2.6.2.dist-info → cmd2-2.7.0.dist-info}/top_level.txt +0 -0
cmd2/argparse_custom.py
CHANGED
@@ -229,14 +229,17 @@ from argparse import (
|
|
229
229
|
ZERO_OR_MORE,
|
230
230
|
ArgumentError,
|
231
231
|
)
|
232
|
-
from collections.abc import
|
233
|
-
|
234
|
-
|
232
|
+
from collections.abc import (
|
233
|
+
Callable,
|
234
|
+
Iterable,
|
235
|
+
Sequence,
|
235
236
|
)
|
237
|
+
from gettext import gettext
|
236
238
|
from typing import (
|
237
239
|
IO,
|
238
240
|
TYPE_CHECKING,
|
239
241
|
Any,
|
242
|
+
ClassVar,
|
240
243
|
NoReturn,
|
241
244
|
Optional,
|
242
245
|
Protocol,
|
@@ -245,6 +248,8 @@ from typing import (
|
|
245
248
|
runtime_checkable,
|
246
249
|
)
|
247
250
|
|
251
|
+
from rich_argparse import RawTextRichHelpFormatter
|
252
|
+
|
248
253
|
from . import (
|
249
254
|
ansi,
|
250
255
|
constants,
|
@@ -991,9 +996,25 @@ setattr(argparse._SubParsersAction, 'remove_parser', _SubParsersAction_remove_pa
|
|
991
996
|
############################################################################################################
|
992
997
|
|
993
998
|
|
994
|
-
class Cmd2HelpFormatter(
|
999
|
+
class Cmd2HelpFormatter(RawTextRichHelpFormatter):
|
995
1000
|
"""Custom help formatter to configure ordering of help text."""
|
996
1001
|
|
1002
|
+
# rich-argparse formats all group names with str.title().
|
1003
|
+
# Override their formatter to do nothing.
|
1004
|
+
group_name_formatter: ClassVar[Callable[[str], str]] = str
|
1005
|
+
|
1006
|
+
# Disable automatic highlighting in the help text.
|
1007
|
+
highlights: ClassVar[list[str]] = []
|
1008
|
+
|
1009
|
+
# Disable markup rendering in usage, help, description, and epilog text.
|
1010
|
+
# cmd2's built-in commands do not escape opening brackets in their help text
|
1011
|
+
# and therefore rely on these settings being False. If you desire to use
|
1012
|
+
# markup in your help text, inherit from Cmd2HelpFormatter and override
|
1013
|
+
# these settings in that child class.
|
1014
|
+
usage_markup: ClassVar[bool] = False
|
1015
|
+
help_markup: ClassVar[bool] = False
|
1016
|
+
text_markup: ClassVar[bool] = False
|
1017
|
+
|
997
1018
|
def _format_usage(
|
998
1019
|
self,
|
999
1020
|
usage: Optional[str],
|
@@ -1215,42 +1236,30 @@ class Cmd2ArgumentParser(argparse.ArgumentParser):
|
|
1215
1236
|
behavior on this parser. If this is None or not present, then cmd2 will use
|
1216
1237
|
argparse_completer.DEFAULT_AP_COMPLETER when tab completing this parser's arguments
|
1217
1238
|
"""
|
1239
|
+
kwargs: dict[str, bool] = {}
|
1218
1240
|
if sys.version_info >= (3, 14):
|
1219
1241
|
# Python >= 3.14 so pass new arguments to parent argparse.ArgumentParser class
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
# Python
|
1239
|
-
|
1240
|
-
|
1241
|
-
usage=usage,
|
1242
|
-
description=description,
|
1243
|
-
epilog=epilog,
|
1244
|
-
parents=parents if parents else [],
|
1245
|
-
formatter_class=formatter_class, # type: ignore[arg-type]
|
1246
|
-
prefix_chars=prefix_chars,
|
1247
|
-
fromfile_prefix_chars=fromfile_prefix_chars,
|
1248
|
-
argument_default=argument_default,
|
1249
|
-
conflict_handler=conflict_handler,
|
1250
|
-
add_help=add_help,
|
1251
|
-
allow_abbrev=allow_abbrev,
|
1252
|
-
exit_on_error=exit_on_error, # added in Python 3.9
|
1253
|
-
)
|
1242
|
+
kwargs = {
|
1243
|
+
"suggest_on_error": suggest_on_error,
|
1244
|
+
"color": color,
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
super().__init__(
|
1248
|
+
prog=prog,
|
1249
|
+
usage=usage,
|
1250
|
+
description=description,
|
1251
|
+
epilog=epilog,
|
1252
|
+
parents=parents if parents else [],
|
1253
|
+
formatter_class=formatter_class, # type: ignore[arg-type]
|
1254
|
+
prefix_chars=prefix_chars,
|
1255
|
+
fromfile_prefix_chars=fromfile_prefix_chars,
|
1256
|
+
argument_default=argument_default,
|
1257
|
+
conflict_handler=conflict_handler,
|
1258
|
+
add_help=add_help,
|
1259
|
+
allow_abbrev=allow_abbrev,
|
1260
|
+
exit_on_error=exit_on_error, # added in Python 3.9
|
1261
|
+
**kwargs, # added in Python 3.14
|
1262
|
+
)
|
1254
1263
|
|
1255
1264
|
self.set_ap_completer_type(ap_completer_type) # type: ignore[attr-defined]
|
1256
1265
|
|
cmd2/cmd2.py
CHANGED
@@ -42,14 +42,16 @@ import re
|
|
42
42
|
import sys
|
43
43
|
import tempfile
|
44
44
|
import threading
|
45
|
-
from code import
|
46
|
-
InteractiveConsole,
|
47
|
-
)
|
45
|
+
from code import InteractiveConsole
|
48
46
|
from collections import (
|
49
47
|
OrderedDict,
|
50
48
|
namedtuple,
|
51
49
|
)
|
52
|
-
from collections.abc import
|
50
|
+
from collections.abc import (
|
51
|
+
Callable,
|
52
|
+
Iterable,
|
53
|
+
Mapping,
|
54
|
+
)
|
53
55
|
from types import (
|
54
56
|
FrameType,
|
55
57
|
ModuleType,
|
@@ -763,8 +765,8 @@ class Cmd(cmd.Cmd):
|
|
763
765
|
"""Build argument parser for a command/subcommand.
|
764
766
|
|
765
767
|
:param parent: CommandParent object which owns the command using the parser.
|
766
|
-
|
767
|
-
|
768
|
+
When parser_builder is a classmethod, this function passes
|
769
|
+
parent's class to it.
|
768
770
|
:param parser_builder: means used to build the parser
|
769
771
|
:param prog: prog value to set in new parser
|
770
772
|
:return: new parser
|
@@ -781,9 +783,7 @@ class Cmd(cmd.Cmd):
|
|
781
783
|
else:
|
782
784
|
raise TypeError(f"Invalid type for parser_builder: {type(parser_builder)}")
|
783
785
|
|
784
|
-
from .decorators import
|
785
|
-
_set_parser_prog,
|
786
|
-
)
|
786
|
+
from .decorators import _set_parser_prog
|
787
787
|
|
788
788
|
_set_parser_prog(parser, prog)
|
789
789
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cmd2
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.7.0
|
4
4
|
Summary: cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python
|
5
5
|
Author: cmd2 Contributors
|
6
6
|
License: The MIT License (MIT)
|
@@ -47,6 +47,7 @@ License-File: LICENSE
|
|
47
47
|
Requires-Dist: gnureadline>=8; platform_system == "Darwin"
|
48
48
|
Requires-Dist: pyperclip>=1.8
|
49
49
|
Requires-Dist: pyreadline3>=3.4; platform_system == "Windows"
|
50
|
+
Requires-Dist: rich-argparse>=1.7.1
|
50
51
|
Requires-Dist: wcwidth>=0.2.10
|
51
52
|
Dynamic: license-file
|
52
53
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
cmd2/__init__.py,sha256=xRXcr4HzJrZbouMEP8AkWwxjW1lqXYLFG0SlWiw5_9g,2502
|
2
2
|
cmd2/ansi.py,sha256=XwBvFnB51LYYjIpfEge6mcr5X63dUxiV0aJlOOJ_2tQ,31965
|
3
3
|
cmd2/argparse_completer.py,sha256=F_5hiX9fYpEhV42mz7v7qeS7KuInAS6xU6KekLxYzsQ,35863
|
4
|
-
cmd2/argparse_custom.py,sha256=
|
4
|
+
cmd2/argparse_custom.py,sha256=uGCQ3MG_iTBvwZ6MKmZOoCjlgF8OvWJg2DMs2myHZf4,59201
|
5
5
|
cmd2/clipboard.py,sha256=HLZWY-W3mkpF_OqQet-F8pS3rlXpiE5vxUyPV_yHvIU,507
|
6
|
-
cmd2/cmd2.py,sha256
|
6
|
+
cmd2/cmd2.py,sha256=8HKnMWhtY0qJUtQZr0ByrMnfYKnavQu7tT6G7wrsZVk,261697
|
7
7
|
cmd2/command_definition.py,sha256=_wF39nig5MP0grSOZ1hFehP5fCGusUNHMn9PIs6pmcU,7648
|
8
8
|
cmd2/constants.py,sha256=duEqGhhvdUV7AYxE8VGZ4wyFBcN2y2bLPd5iefW4tSU,1943
|
9
9
|
cmd2/decorators.py,sha256=t0gBy3aRz5ke0jHyP5YOszdQ61t5aV8j0eNyLPX6hmg,20644
|
@@ -17,8 +17,8 @@ cmd2/rl_utils.py,sha256=sWapqwDR_GvOgy5NJ7c-i6nUU4dqpKpGQ8-Olwi3tuU,11335
|
|
17
17
|
cmd2/table_creator.py,sha256=nF3VEgGHvfhHBh_yoMAiV1WaDdR8hIareIAogzIPq5M,47177
|
18
18
|
cmd2/transcript.py,sha256=Ws0lW_oBFxCQCKSwvnDUS1x3ya163YXnV-O5aTU0z7k,9207
|
19
19
|
cmd2/utils.py,sha256=NqDIkY4LiAlnv_Un7MFHxszoH2KgEWQ7NJOwQurIn_E,50698
|
20
|
-
cmd2-2.
|
21
|
-
cmd2-2.
|
22
|
-
cmd2-2.
|
23
|
-
cmd2-2.
|
24
|
-
cmd2-2.
|
20
|
+
cmd2-2.7.0.dist-info/licenses/LICENSE,sha256=9qPeHY4u2fkSz0JQGT-P4T3QqTWTqnQJ_8LkZUhSdFY,1099
|
21
|
+
cmd2-2.7.0.dist-info/METADATA,sha256=HOqT-x9vnZ21-fCTSbT7HC-BQo6fPY1hyCXtS_b6GHw,17328
|
22
|
+
cmd2-2.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
cmd2-2.7.0.dist-info/top_level.txt,sha256=gJbOJmyrARwLhm5diXAtzlNQdxbDZ8iRJ8HJi65_5hg,5
|
24
|
+
cmd2-2.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|