cmd2 2.5.2__py3-none-any.whl → 2.5.3__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/cmd2.py CHANGED
@@ -3404,8 +3404,7 @@ class Cmd(cmd.Cmd):
3404
3404
  alias_description = "Manage aliases\n" "\n" "An alias is a command that enables replacement of a word by another string."
3405
3405
  alias_epilog = "See also:\n" " macro"
3406
3406
  alias_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=alias_description, epilog=alias_epilog)
3407
- alias_subparsers = alias_parser.add_subparsers(dest='subcommand', metavar='SUBCOMMAND')
3408
- alias_subparsers.required = True
3407
+ alias_parser.add_subparsers(dest='subcommand', metavar='SUBCOMMAND', required=True)
3409
3408
 
3410
3409
  # Preserve quotes since we are passing strings to other commands
3411
3410
  @with_argparser(alias_parser, preserve_quotes=True)
@@ -3573,8 +3572,7 @@ class Cmd(cmd.Cmd):
3573
3572
  macro_description = "Manage macros\n" "\n" "A macro is similar to an alias, but it can contain argument placeholders."
3574
3573
  macro_epilog = "See also:\n" " alias"
3575
3574
  macro_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=macro_description, epilog=macro_epilog)
3576
- macro_subparsers = macro_parser.add_subparsers(dest='subcommand', metavar='SUBCOMMAND')
3577
- macro_subparsers.required = True
3575
+ macro_parser.add_subparsers(dest='subcommand', metavar='SUBCOMMAND', required=True)
3578
3576
 
3579
3577
  # Preserve quotes since we are passing strings to other commands
3580
3578
  @with_argparser(macro_parser, preserve_quotes=True)
@@ -92,10 +92,31 @@ class CommandSet(object):
92
92
  """
93
93
 
94
94
  def __init__(self) -> None:
95
- self._cmd: Optional[cmd2.Cmd] = None
95
+ # Private reference to the CLI instance in which this CommandSet running.
96
+ # This will be set when the CommandSet is registered and it should be
97
+ # accessed by child classes using the self._cmd property.
98
+ self.__cmd_internal: Optional[cmd2.Cmd] = None
99
+
96
100
  self._settables: Dict[str, Settable] = {}
97
101
  self._settable_prefix = self.__class__.__name__
98
102
 
103
+ @property
104
+ def _cmd(self) -> 'cmd2.Cmd':
105
+ """
106
+ Property for child classes to access self.__cmd_internal.
107
+
108
+ Using this property ensures that self.__cmd_internal has been set
109
+ and it tells type checkers that it's no longer a None type.
110
+
111
+ Override this property if you need to change its return type to a
112
+ child class of Cmd.
113
+
114
+ :raises: CommandSetRegistrationError if CommandSet is not registered.
115
+ """
116
+ if self.__cmd_internal is None:
117
+ raise CommandSetRegistrationError('This CommandSet is not registered')
118
+ return self.__cmd_internal
119
+
99
120
  def on_register(self, cmd: 'cmd2.Cmd') -> None:
100
121
  """
101
122
  Called by cmd2.Cmd as the first step to registering a CommandSet. The commands defined in this class have
@@ -103,9 +124,10 @@ class CommandSet(object):
103
124
  requiring access to the Cmd object (e.g. configure commands and their parsers based on CLI state data).
104
125
 
105
126
  :param cmd: The cmd2 main application
127
+ :raises: CommandSetRegistrationError if CommandSet is already registered.
106
128
  """
107
- if self._cmd is None:
108
- self._cmd = cmd
129
+ if self.__cmd_internal is None:
130
+ self.__cmd_internal = cmd
109
131
  else:
110
132
  raise CommandSetRegistrationError('This CommandSet has already been registered')
111
133
 
@@ -129,7 +151,7 @@ class CommandSet(object):
129
151
  Called by ``cmd2.Cmd`` after a CommandSet has been unregistered and all its commands removed from the CLI.
130
152
  Subclasses can override this to perform remaining cleanup steps.
131
153
  """
132
- self._cmd = None
154
+ self.__cmd_internal = None
133
155
 
134
156
  @property
135
157
  def settable_prefix(self) -> str:
@@ -145,7 +167,7 @@ class CommandSet(object):
145
167
 
146
168
  :param settable: Settable object being added
147
169
  """
148
- if self._cmd:
170
+ if self.__cmd_internal is not None:
149
171
  if not self._cmd.always_prefix_settables:
150
172
  if settable.name in self._cmd.settables.keys() and settable.name not in self._settables.keys():
151
173
  raise KeyError(f'Duplicate settable: {settable.name}')
@@ -1,62 +1,81 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmd2
3
- Version: 2.5.2
3
+ Version: 2.5.3
4
4
  Summary: cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python
5
- Home-page: https://github.com/python-cmd2/cmd2
6
- Author: Catherine Devlin
7
- Author-email: catherine.devlin@gmail.com
8
- License: MIT
9
- Keywords: command prompt console cmd
10
- Platform: any
5
+ Author: cmd2 Contributors
6
+ License: The MIT License (MIT)
7
+
8
+ Copyright (c) 2008-2024 Catherine Devlin and others
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ Keywords: CLI,cmd,command,interactive,prompt,Python
11
29
  Classifier: Development Status :: 5 - Production/Stable
12
30
  Classifier: Environment :: Console
13
31
  Classifier: Operating System :: OS Independent
14
32
  Classifier: Intended Audience :: Developers
15
33
  Classifier: Intended Audience :: System Administrators
16
34
  Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Programming Language :: Python
18
- Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3 :: Only
19
36
  Classifier: Programming Language :: Python :: 3.8
20
37
  Classifier: Programming Language :: Python :: 3.9
21
38
  Classifier: Programming Language :: Python :: 3.10
22
39
  Classifier: Programming Language :: Python :: 3.11
23
40
  Classifier: Programming Language :: Python :: 3.12
24
41
  Classifier: Programming Language :: Python :: 3.13
25
- Classifier: Programming Language :: Python :: Implementation :: CPython
26
42
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
43
  Requires-Python: >=3.8
28
44
  Description-Content-Type: text/markdown
29
45
  License-File: LICENSE
30
46
  Requires-Dist: pyperclip
31
47
  Requires-Dist: wcwidth
32
- Requires-Dist: pyreadline3 ; sys_platform=='win32'
48
+ Requires-Dist: gnureadline ; platform_system == "Darwin"
49
+ Requires-Dist: pyreadline3 ; platform_system == "Windows"
50
+ Provides-Extra: build
51
+ Requires-Dist: build ; extra == 'build'
52
+ Requires-Dist: setuptools ; extra == 'build'
53
+ Requires-Dist: setuptools-scm ; extra == 'build'
33
54
  Provides-Extra: dev
34
55
  Requires-Dist: codecov ; extra == 'dev'
35
56
  Requires-Dist: doc8 ; extra == 'dev'
36
57
  Requires-Dist: invoke ; extra == 'dev'
37
58
  Requires-Dist: mypy ; extra == 'dev'
38
- Requires-Dist: nox ; extra == 'dev'
39
- Requires-Dist: pytest >=4.6 ; extra == 'dev'
59
+ Requires-Dist: pytest ; extra == 'dev'
40
60
  Requires-Dist: pytest-cov ; extra == 'dev'
41
61
  Requires-Dist: pytest-mock ; extra == 'dev'
42
62
  Requires-Dist: sphinx ; extra == 'dev'
43
- Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
44
63
  Requires-Dist: sphinx-autobuild ; extra == 'dev'
64
+ Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
45
65
  Requires-Dist: ruff ; extra == 'dev'
46
66
  Requires-Dist: twine ; extra == 'dev'
47
67
  Provides-Extra: docs
48
68
  Requires-Dist: setuptools ; extra == 'docs'
49
69
  Requires-Dist: setuptools-scm ; extra == 'docs'
50
70
  Requires-Dist: sphinx ; extra == 'docs'
51
- Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
52
71
  Requires-Dist: sphinx-autobuild ; extra == 'docs'
72
+ Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
53
73
  Provides-Extra: test
54
74
  Requires-Dist: codecov ; extra == 'test'
55
75
  Requires-Dist: coverage ; extra == 'test'
56
76
  Requires-Dist: pytest ; extra == 'test'
57
77
  Requires-Dist: pytest-cov ; extra == 'test'
58
78
  Requires-Dist: pytest-mock ; extra == 'test'
59
- Requires-Dist: gnureadline ; (sys_platform == "darwin") and extra == 'test'
60
79
  Provides-Extra: validate
61
80
  Requires-Dist: mypy ; extra == 'validate'
62
81
  Requires-Dist: ruff ; extra == 'validate'
@@ -3,8 +3,8 @@ cmd2/ansi.py,sha256=BasPj_Wla0cEyjpe_zu-cn24CgVdSXK3sfxknLM1WcY,32203
3
3
  cmd2/argparse_completer.py,sha256=6z0zmODqM7vhQhI0c6JUvCmR2V4qfdWQEyTZeNIea8c,36505
4
4
  cmd2/argparse_custom.py,sha256=bbAYRr79ZSJWGchd7trmRQDHWAsSJaW0dTQMp65Mrv4,57806
5
5
  cmd2/clipboard.py,sha256=7EISono76d7djj17hbvR9cCTB7jVGSBkUjgVQiMyUjE,549
6
- cmd2/cmd2.py,sha256=fAw7vGAwjw0-3rWL2uUsm-MWEpQXhKxbmLdUhwf_K-4,261420
7
- cmd2/command_definition.py,sha256=jm15jQoskQLn5vhvxJinvjHg0KYhzydDU67Dkl734z4,6592
6
+ cmd2/cmd2.py,sha256=u7wS8guAuSIQYWy7jnyPDkXHCzFLK8881nrvhjzgzio,261338
7
+ cmd2/command_definition.py,sha256=U5Bx2MwsK2JWUKzmFm4u9OhRgJqp-2r2Q85qsKWCdXQ,7585
8
8
  cmd2/constants.py,sha256=O5SfjAZGgCl5-IxuHqBMmgbG3HhllxIcZBtkzzLYohA,1865
9
9
  cmd2/decorators.py,sha256=wM0PtalUseDfJVVQV2LkbZbqkZad2XudRiCmARCBWWs,20658
10
10
  cmd2/exceptions.py,sha256=DwX7rQmon4eRyX1ZK4yne4lObdPO1j5Agg3Bav6pXwU,3600
@@ -17,8 +17,8 @@ cmd2/rl_utils.py,sha256=HVPdNjuYyU67-XerPUJArmzhohzI1ABrZhU9cLc-EIs,11538
17
17
  cmd2/table_creator.py,sha256=qoxt9s3MxQkfSkp4cIPFMlVzC7kRjUU55p0ow7pFQus,47544
18
18
  cmd2/transcript.py,sha256=I0sD38RbG79Qz9GXIlfh1pHSNmWBTY2SLZAKEdSLWI4,9182
19
19
  cmd2/utils.py,sha256=M6Ojtq3QQ7NbuvgIcxmhEaN2o-OcxkI_LAXZIxu7DF4,49383
20
- cmd2-2.5.2.dist-info/LICENSE,sha256=QXrW0Z0merk9mncyUkn-sgRxhT8_o1dL5HEaBNH47Q4,1099
21
- cmd2-2.5.2.dist-info/METADATA,sha256=IO61KMLQi8_KrUDkJeqikYq3R3bwWVFQ2EtMM92BWXg,12135
22
- cmd2-2.5.2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
23
- cmd2-2.5.2.dist-info/top_level.txt,sha256=gJbOJmyrARwLhm5diXAtzlNQdxbDZ8iRJ8HJi65_5hg,5
24
- cmd2-2.5.2.dist-info/RECORD,,
20
+ cmd2-2.5.3.dist-info/LICENSE,sha256=QXrW0Z0merk9mncyUkn-sgRxhT8_o1dL5HEaBNH47Q4,1099
21
+ cmd2-2.5.3.dist-info/METADATA,sha256=7StjZqH093MfR0b6B-8AKVwDZDXpLr0eSg5XwwQIAoQ,13308
22
+ cmd2-2.5.3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
23
+ cmd2-2.5.3.dist-info/top_level.txt,sha256=gJbOJmyrARwLhm5diXAtzlNQdxbDZ8iRJ8HJi65_5hg,5
24
+ cmd2-2.5.3.dist-info/RECORD,,
File without changes
File without changes