cmd2 2.5.8__py3-none-any.whl → 2.5.10__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/ansi.py CHANGED
@@ -165,7 +165,7 @@ def clear_screen(clear_type: int = 2) -> str:
165
165
  2 - clear entire screen
166
166
  3 - clear entire screen and delete all lines saved in the scrollback buffer
167
167
  :return: the clear screen string
168
- :raises: ValueError if clear_type is not a valid value
168
+ :raises ValueError: if clear_type is not a valid value
169
169
  """
170
170
  if 0 <= clear_type <= 3:
171
171
  return f"{CSI}{clear_type}J"
@@ -182,7 +182,7 @@ def clear_line(clear_type: int = 2) -> str:
182
182
  1 - clear from cursor to beginning of the line
183
183
  2 - clear entire line
184
184
  :return: the clear line string
185
- :raises: ValueError if clear_type is not a valid value
185
+ :raises ValueError: if clear_type is not a valid value
186
186
  """
187
187
  if 0 <= clear_type <= 2:
188
188
  return f"{CSI}{clear_type}K"
@@ -915,7 +915,7 @@ class RgbFg(FgColor):
915
915
  :param r: integer from 0-255 for the red component of the color
916
916
  :param g: integer from 0-255 for the green component of the color
917
917
  :param b: integer from 0-255 for the blue component of the color
918
- :raises: ValueError if r, g, or b is not in the range 0-255
918
+ :raises ValueError: if r, g, or b is not in the range 0-255
919
919
  """
920
920
  if any(c < 0 or c > 255 for c in [r, g, b]):
921
921
  raise ValueError("RGB values must be integers in the range of 0 to 255")
@@ -944,7 +944,7 @@ class RgbBg(BgColor):
944
944
  :param r: integer from 0-255 for the red component of the color
945
945
  :param g: integer from 0-255 for the green component of the color
946
946
  :param b: integer from 0-255 for the blue component of the color
947
- :raises: ValueError if r, g, or b is not in the range 0-255
947
+ :raises ValueError: if r, g, or b is not in the range 0-255
948
948
  """
949
949
  if any(c < 0 or c > 255 for c in [r, g, b]):
950
950
  raise ValueError("RGB values must be integers in the range of 0 to 255")
@@ -988,8 +988,8 @@ def style(
988
988
  :param overline: apply the overline style if True. Defaults to False.
989
989
  :param strikethrough: apply the strikethrough style if True. Defaults to False.
990
990
  :param underline: apply the underline style if True. Defaults to False.
991
- :raises: TypeError if fg isn't None or a subclass of FgColor
992
- :raises: TypeError if bg isn't None or a subclass of BgColor
991
+ :raises TypeError: if fg isn't None or a subclass of FgColor
992
+ :raises TypeError: if bg isn't None or a subclass of BgColor
993
993
  :return: the stylized string
994
994
  """
995
995
  # List of strings that add style
@@ -1043,13 +1043,13 @@ def style(
1043
1043
  # These can be altered to suit an application's needs and only need to be a
1044
1044
  # function with the following structure: func(str) -> str
1045
1045
  style_success = functools.partial(style, fg=Fg.GREEN)
1046
- """Partial function supplying arguments to :meth:`cmd2.ansi.style()` which colors text to signify success"""
1046
+ """Partial function supplying arguments to [cmd2.ansi.style][] which colors text to signify success"""
1047
1047
 
1048
1048
  style_warning = functools.partial(style, fg=Fg.LIGHT_YELLOW)
1049
- """Partial function supplying arguments to :meth:`cmd2.ansi.style()` which colors text to signify a warning"""
1049
+ """Partial function supplying arguments to [cmd2.ansi.style][] which colors text to signify a warning"""
1050
1050
 
1051
1051
  style_error = functools.partial(style, fg=Fg.LIGHT_RED)
1052
- """Partial function supplying arguments to :meth:`cmd2.ansi.style()` which colors text to signify an error"""
1052
+ """Partial function supplying arguments to [cmd2.ansi.style][] which colors text to signify an error"""
1053
1053
 
1054
1054
 
1055
1055
  def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_offset: int, alert_msg: str) -> str:
@@ -226,7 +226,7 @@ class ArgparseCompleter:
226
226
  :param cmd_set: if tab completing a command, the CommandSet the command's function belongs to, if applicable.
227
227
  Defaults to None.
228
228
 
229
- :raises: CompletionError for various types of tab completion errors
229
+ :raises CompletionError: for various types of tab completion errors
230
230
  """
231
231
  if not tokens:
232
232
  return []
@@ -264,7 +264,7 @@ class ArgparseCompleter:
264
264
  Check if an argument belongs to a mutually exclusive group and either mark that group
265
265
  as complete or print an error if the group has already been completed
266
266
  :param arg_action: the action of the argument
267
- :raises: CompletionError if the group is already completed
267
+ :raises CompletionError: if the group is already completed
268
268
  """
269
269
  # Check if this action is in a mutually exclusive group
270
270
  for group in self._parser._mutually_exclusive_groups:
@@ -679,7 +679,7 @@ class ArgparseCompleter:
679
679
  """
680
680
  Tab completion routine for an argparse argument
681
681
  :return: list of completions
682
- :raises: CompletionError if the completer or choices function this calls raises one
682
+ :raises CompletionError: if the completer or choices function this calls raises one
683
683
  """
684
684
  # Check if the arg provides choices to the user
685
685
  arg_choices: Union[List[str], ChoicesCallable]
cmd2/argparse_custom.py CHANGED
@@ -198,31 +198,20 @@ more details.
198
198
  cmd2 has patched ``argparse.Action`` to include the following accessor methods
199
199
  for cases in which you need to manually access the cmd2-specific attributes.
200
200
 
201
- - ``argparse.Action.get_choices_callable()`` - See
202
- :func:`_action_get_choices_callable` for more details.
203
- - ``argparse.Action.set_choices_provider()`` - See
204
- :func:`_action_set_choices_provider` for more details.
205
- - ``argparse.Action.set_completer()`` - See
206
- :func:`_action_set_completer` for more details.
207
- - ``argparse.Action.get_descriptive_header()`` - See
208
- :func:`_action_get_descriptive_header` for more details.
209
- - ``argparse.Action.set_descriptive_header()`` - See
210
- :func:`_action_set_descriptive_header` for more details.
211
- - ``argparse.Action.get_nargs_range()`` - See
212
- :func:`_action_get_nargs_range` for more details.
213
- - ``argparse.Action.set_nargs_range()`` - See
214
- :func:`_action_set_nargs_range` for more details.
215
- - ``argparse.Action.get_suppress_tab_hint()`` - See
216
- :func:`_action_get_suppress_tab_hint` for more details.
217
- - ``argparse.Action.set_suppress_tab_hint()`` - See
218
- :func:`_action_set_suppress_tab_hint` for more details.
201
+ - ``argparse.Action.get_choices_callable()`` - See `action_get_choices_callable` for more details.
202
+ - ``argparse.Action.set_choices_provider()`` - See `_action_set_choices_provider` for more details.
203
+ - ``argparse.Action.set_completer()`` - See `_action_set_completer` for more details.
204
+ - ``argparse.Action.get_descriptive_header()`` - See `_action_get_descriptive_header` for more details.
205
+ - ``argparse.Action.set_descriptive_header()`` - See `_action_set_descriptive_header` for more details.
206
+ - ``argparse.Action.get_nargs_range()`` - See `_action_get_nargs_range` for more details.
207
+ - ``argparse.Action.set_nargs_range()`` - See `_action_set_nargs_range` for more details.
208
+ - ``argparse.Action.get_suppress_tab_hint()`` - See `_action_get_suppress_tab_hint` for more details.
209
+ - ``argparse.Action.set_suppress_tab_hint()`` - See `_action_set_suppress_tab_hint` for more details.
219
210
 
220
211
  cmd2 has patched ``argparse.ArgumentParser`` to include the following accessor methods
221
212
 
222
- - ``argparse.ArgumentParser.get_ap_completer_type()`` - See
223
- :func:`_ArgumentParser_get_ap_completer_type` for more details.
224
- - ``argparse.Action.set_ap_completer_type()`` - See
225
- :func:`_ArgumentParser_set_ap_completer_type` for more details.
213
+ - ``argparse.ArgumentParser.get_ap_completer_type()`` - See `_ArgumentParser_get_ap_completer_type` for more details.
214
+ - ``argparse.Action.set_ap_completer_type()`` - See `_ArgumentParser_set_ap_completer_type` for more details.
226
215
 
227
216
  **Subcommand removal**
228
217
 
@@ -230,8 +219,7 @@ cmd2 has patched ``argparse._SubParsersAction`` to include a ``remove_parser()``
230
219
  method which can be used to remove a subcommand.
231
220
 
232
221
  ``argparse._SubParsersAction.remove_parser`` - new function which removes a
233
- sub-parser from a sub-parsers group. See
234
- :func:`_SubParsersAction_remove_parser` for more details.
222
+ sub-parser from a sub-parsers group. See _SubParsersAction_remove_parser` for more details.
235
223
  """
236
224
 
237
225
  import argparse
@@ -312,7 +300,6 @@ class CompletionItem(str):
312
300
  :param value: the value being tab completed
313
301
  :param description: description text to display
314
302
  :param args: args for str __init__
315
- :param kwargs: kwargs for str __init__
316
303
  """
317
304
  super().__init__(*args)
318
305
  self.description = description
@@ -485,16 +472,15 @@ def _action_set_choices_callable(self: argparse.Action, choices_callable: Choice
485
472
 
486
473
  :param self: action being edited
487
474
  :param choices_callable: the ChoicesCallable instance to use
488
- :raises: TypeError if used on incompatible action type
475
+ :raises TypeError: if used on incompatible action type
489
476
  """
490
477
  # Verify consistent use of parameters
491
478
  if self.choices is not None:
492
- err_msg = "None of the following parameters can be used alongside a choices parameter:\n" "choices_provider, completer"
479
+ err_msg = "None of the following parameters can be used alongside a choices parameter:\nchoices_provider, completer"
493
480
  raise (TypeError(err_msg))
494
481
  elif self.nargs == 0:
495
482
  err_msg = (
496
- "None of the following parameters can be used on an action that takes no arguments:\n"
497
- "choices_provider, completer"
483
+ "None of the following parameters can be used on an action that takes no arguments:\nchoices_provider, completer"
498
484
  )
499
485
  raise (TypeError(err_msg))
500
486
 
@@ -517,7 +503,7 @@ def _action_set_choices_provider(
517
503
 
518
504
  :param self: action being edited
519
505
  :param choices_provider: the choices_provider instance to use
520
- :raises: TypeError if used on incompatible action type
506
+ :raises TypeError: if used on incompatible action type
521
507
  """
522
508
  self._set_choices_callable(ChoicesCallable(is_completer=False, to_call=choices_provider)) # type: ignore[attr-defined]
523
509
 
@@ -538,7 +524,7 @@ def _action_set_completer(
538
524
 
539
525
  :param self: action being edited
540
526
  :param completer: the completer instance to use
541
- :raises: TypeError if used on incompatible action type
527
+ :raises TypeError: if used on incompatible action type
542
528
  """
543
529
  self._set_choices_callable(ChoicesCallable(is_completer=True, to_call=completer)) # type: ignore[attr-defined]
544
530
 
@@ -771,14 +757,14 @@ def _add_argument_wrapper(
771
757
  See the header of this file for more information
772
758
 
773
759
  :return: the created argument action
774
- :raises: ValueError on incorrect parameter usage
760
+ :raises ValueError: on incorrect parameter usage
775
761
  """
776
762
  # Verify consistent use of arguments
777
763
  choices_callables = [choices_provider, completer]
778
764
  num_params_set = len(choices_callables) - choices_callables.count(None)
779
765
 
780
766
  if num_params_set > 1:
781
- err_msg = "Only one of the following parameters may be used at a time:\n" "choices_provider, completer"
767
+ err_msg = "Only one of the following parameters may be used at a time:\nchoices_provider, completer"
782
768
  raise (ValueError(err_msg))
783
769
 
784
770
  # Pre-process special ranged nargs
cmd2/cmd2.py CHANGED
@@ -305,7 +305,7 @@ class Cmd(cmd.Cmd):
305
305
  DEFAULT_EDITOR = utils.find_editor()
306
306
 
307
307
  INTERNAL_COMMAND_EPILOG = (
308
- "Notes:\n" " This command is for internal use and is not intended to be called from the\n" " command line."
308
+ "Notes:\n This command is for internal use and is not intended to be called from the\n command line."
309
309
  )
310
310
 
311
311
  # Sorting keys for strings
@@ -349,7 +349,7 @@ class Cmd(cmd.Cmd):
349
349
  suppressed. Anything written to stderr will still display.
350
350
  :param include_py: should the "py" command be included for an embedded Python shell
351
351
  :param include_ipy: should the "ipy" command be included for an embedded IPython shell
352
- :param allow_cli_args: if ``True``, then :meth:`cmd2.Cmd.__init__` will process command
352
+ :param allow_cli_args: if ``True``, then [cmd2.Cmd.__init__][] will process command
353
353
  line arguments as either commands to be run or, if ``-t`` or
354
354
  ``--test`` are given, transcript files to run. This should be
355
355
  set to ``False`` if your application parses its own command line
@@ -1134,7 +1134,7 @@ class Cmd(cmd.Cmd):
1134
1134
  Convenience method for removing a settable parameter from ``self.settables``
1135
1135
 
1136
1136
  :param name: name of the settable being removed
1137
- :raises: KeyError if the Settable matches this name
1137
+ :raises KeyError: if the Settable matches this name
1138
1138
  """
1139
1139
  try:
1140
1140
  del self._settables[name]
@@ -2446,50 +2446,47 @@ class Cmd(cmd.Cmd):
2446
2446
 
2447
2447
  def precmd(self, statement: Union[Statement, str]) -> Statement:
2448
2448
  """Hook method executed just before the command is executed by
2449
- :meth:`~cmd2.Cmd.onecmd` and after adding it to history.
2449
+ [cmd2.Cmd.onecmd][] and after adding it to history.
2450
2450
 
2451
2451
  :param statement: subclass of str which also contains the parsed input
2452
2452
  :return: a potentially modified version of the input Statement object
2453
2453
 
2454
- See :meth:`~cmd2.Cmd.register_postparsing_hook` and
2455
- :meth:`~cmd2.Cmd.register_precmd_hook` for more robust ways
2454
+ See [cmd2.Cmd.register_postparsing_hook][] and
2455
+ [cmd2.Cmd.register_precmd_hook][] for more robust ways
2456
2456
  to run hooks before the command is executed. See
2457
- :ref:`features/hooks:Postparsing Hooks` and
2458
- :ref:`features/hooks:Precommand Hooks` for more information.
2457
+ [Hooks](../features/hooks.md) for more information.
2459
2458
  """
2460
2459
  return Statement(statement) if not isinstance(statement, Statement) else statement
2461
2460
 
2462
2461
  def postcmd(self, stop: bool, statement: Union[Statement, str]) -> bool:
2463
2462
  """Hook method executed just after a command is executed by
2464
- :meth:`~cmd2.Cmd.onecmd`.
2463
+ [cmd2.Cmd.onecmd][].
2465
2464
 
2466
2465
  :param stop: return `True` to request the command loop terminate
2467
2466
  :param statement: subclass of str which also contains the parsed input
2468
2467
 
2469
- See :meth:`~cmd2.Cmd.register_postcmd_hook` and :meth:`~cmd2.Cmd.register_cmdfinalization_hook` for more robust ways
2468
+ See [cmd2.Cmd.register_postcmd_hook][] and [cmd2.Cmd.register_cmdfinalization_hook][] for more robust ways
2470
2469
  to run hooks after the command is executed. See
2471
- :ref:`features/hooks:Postcommand Hooks` and
2472
- :ref:`features/hooks:Command Finalization Hooks` for more information.
2470
+ [Hooks](../features/hooks.md) for more information.
2473
2471
  """
2474
2472
  return stop
2475
2473
 
2476
2474
  def preloop(self) -> None:
2477
- """Hook method executed once when the :meth:`~.cmd2.Cmd.cmdloop()`
2475
+ """Hook method executed once when the [cmd2.Cmd.cmdloop][]
2478
2476
  method is called.
2479
2477
 
2480
- See :meth:`~cmd2.Cmd.register_preloop_hook` for a more robust way
2478
+ See [cmd2.Cmd.register_preloop_hook][] for a more robust way
2481
2479
  to run hooks before the command loop begins. See
2482
- :ref:`features/hooks:Application Lifecycle Hooks` for more information.
2480
+ [Hooks](../features/hooks.md) for more information.
2483
2481
  """
2484
2482
  pass
2485
2483
 
2486
2484
  def postloop(self) -> None:
2487
- """Hook method executed once when the :meth:`~.cmd2.Cmd.cmdloop()`
2488
- method is about to return.
2485
+ """Hook method executed once when the [cmd2.Cmd.cmdloop][] method is about to return.
2489
2486
 
2490
- See :meth:`~cmd2.Cmd.register_postloop_hook` for a more robust way
2487
+ See [cmd2.Cmd.register_postloop_hook][] for a more robust way
2491
2488
  to run hooks after the command loop completes. See
2492
- :ref:`features/hooks:Application Lifecycle Hooks` for more information.
2489
+ [Hooks](../features/hooks.md) for more information.
2493
2490
  """
2494
2491
  pass
2495
2492
 
@@ -2704,8 +2701,8 @@ class Cmd(cmd.Cmd):
2704
2701
  This is used to assist in combining multiline readline history entries and is only
2705
2702
  populated by cmd2. Defaults to None.
2706
2703
  :return: the completed Statement
2707
- :raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
2708
- :raises: EmptyStatement when the resulting Statement is blank
2704
+ :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
2705
+ :raises EmptyStatement: when the resulting Statement is blank
2709
2706
  """
2710
2707
 
2711
2708
  def combine_rl_history(statement: Statement) -> None:
@@ -2791,8 +2788,8 @@ class Cmd(cmd.Cmd):
2791
2788
  This is used to assist in combining multiline readline history entries and is only
2792
2789
  populated by cmd2. Defaults to None.
2793
2790
  :return: parsed command line as a Statement
2794
- :raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
2795
- :raises: EmptyStatement when the resulting Statement is blank
2791
+ :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
2792
+ :raises EmptyStatement: when the resulting Statement is blank
2796
2793
  """
2797
2794
  used_macros = []
2798
2795
  orig_line = None
@@ -2882,7 +2879,7 @@ class Cmd(cmd.Cmd):
2882
2879
 
2883
2880
  :param statement: a parsed statement from the user
2884
2881
  :return: A bool telling if an error occurred and a utils.RedirectionSavedState object
2885
- :raises: RedirectionError if an error occurs trying to pipe or redirect
2882
+ :raises RedirectionError: if an error occurs trying to pipe or redirect
2886
2883
  """
2887
2884
  import io
2888
2885
  import subprocess
@@ -3028,9 +3025,11 @@ class Cmd(cmd.Cmd):
3028
3025
 
3029
3026
  :param command: the name of the command
3030
3027
 
3031
- :Example:
3028
+ Example:
3032
3029
 
3033
- >>> helpfunc = self.cmd_func('help')
3030
+ ```py
3031
+ helpfunc = self.cmd_func('help')
3032
+ ```
3034
3033
 
3035
3034
  helpfunc now contains a reference to the ``do_help`` method
3036
3035
  """
@@ -3136,7 +3135,7 @@ class Cmd(cmd.Cmd):
3136
3135
  :param parser: an argument parser which supports the tab completion of multiple arguments
3137
3136
 
3138
3137
  :return: the line read from stdin with all trailing new lines removed
3139
- :raises: any exceptions raised by input() and stdin.readline()
3138
+ :raises Exception: any exceptions raised by input() and stdin.readline()
3140
3139
  """
3141
3140
  readline_configured = False
3142
3141
  saved_completer: Optional[CompleterFunc] = None
@@ -3261,7 +3260,7 @@ class Cmd(cmd.Cmd):
3261
3260
 
3262
3261
  :param prompt: prompt to display to user
3263
3262
  :return: command line text of 'eof' if an EOFError was caught
3264
- :raises: whatever exceptions are raised by input() except for EOFError
3263
+ :raises Exception: whatever exceptions are raised by input() except for EOFError
3265
3264
  """
3266
3265
  try:
3267
3266
  # Wrap in try since terminal_lock may not be locked
@@ -3381,8 +3380,8 @@ class Cmd(cmd.Cmd):
3381
3380
  #############################################################
3382
3381
 
3383
3382
  # Top-level parser for alias
3384
- alias_description = "Manage aliases\n" "\n" "An alias is a command that enables replacement of a word by another string."
3385
- alias_epilog = "See also:\n" " macro"
3383
+ alias_description = "Manage aliases\n\nAn alias is a command that enables replacement of a word by another string."
3384
+ alias_epilog = "See also:\n macro"
3386
3385
  alias_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=alias_description, epilog=alias_epilog)
3387
3386
  alias_parser.add_subparsers(metavar='SUBCOMMAND', required=True)
3388
3387
 
@@ -3549,8 +3548,8 @@ class Cmd(cmd.Cmd):
3549
3548
  #############################################################
3550
3549
 
3551
3550
  # Top-level parser for macro
3552
- macro_description = "Manage macros\n" "\n" "A macro is similar to an alias, but it can contain argument placeholders."
3553
- macro_epilog = "See also:\n" " alias"
3551
+ macro_description = "Manage macros\n\nA macro is similar to an alias, but it can contain argument placeholders."
3552
+ macro_epilog = "See also:\n alias"
3554
3553
  macro_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=macro_description, epilog=macro_epilog)
3555
3554
  macro_parser.add_subparsers(metavar='SUBCOMMAND', required=True)
3556
3555
 
@@ -3807,7 +3806,7 @@ class Cmd(cmd.Cmd):
3807
3806
  return completer.complete_subcommand_help(text, line, begidx, endidx, arg_tokens['subcommands'])
3808
3807
 
3809
3808
  help_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
3810
- description="List available commands or provide " "detailed help for a specific command"
3809
+ description="List available commands or provide detailed help for a specific command"
3811
3810
  )
3812
3811
  help_parser.add_argument(
3813
3812
  '-v', '--verbose', action='store_true', help="print a list of all commands with descriptions of each"
@@ -4700,22 +4699,22 @@ class Cmd(cmd.Cmd):
4700
4699
 
4701
4700
  history_format_group = history_parser.add_argument_group(title='formatting')
4702
4701
  history_format_group.add_argument(
4703
- '-s', '--script', action='store_true', help='output commands in script format, i.e. without command\n' 'numbers'
4702
+ '-s', '--script', action='store_true', help='output commands in script format, i.e. without command\nnumbers'
4704
4703
  )
4705
4704
  history_format_group.add_argument(
4706
4705
  '-x',
4707
4706
  '--expanded',
4708
4707
  action='store_true',
4709
- help='output fully parsed commands with any aliases and\n' 'macros expanded, instead of typed commands',
4708
+ help='output fully parsed commands with any aliases and\nmacros expanded, instead of typed commands',
4710
4709
  )
4711
4710
  history_format_group.add_argument(
4712
4711
  '-v',
4713
4712
  '--verbose',
4714
4713
  action='store_true',
4715
- help='display history and include expanded commands if they\n' 'differ from the typed command',
4714
+ help='display history and include expanded commands if they\ndiffer from the typed command',
4716
4715
  )
4717
4716
  history_format_group.add_argument(
4718
- '-a', '--all', action='store_true', help='display all commands, including ones persisted from\n' 'previous sessions'
4717
+ '-a', '--all', action='store_true', help='display all commands, including ones persisted from\nprevious sessions'
4719
4718
  )
4720
4719
 
4721
4720
  history_arg_help = (
@@ -5081,7 +5080,7 @@ class Cmd(cmd.Cmd):
5081
5080
  Run a text editor and optionally open a file with it
5082
5081
 
5083
5082
  :param file_path: optional path of the file to edit. Defaults to None.
5084
- :raises: EnvironmentError if self.editor is not set
5083
+ :raises EnvironmentError: if self.editor is not set
5085
5084
  """
5086
5085
  if not self.editor:
5087
5086
  raise EnvironmentError("Please use 'set editor' to specify your text editing program of choice.")
@@ -5190,7 +5189,7 @@ class Cmd(cmd.Cmd):
5190
5189
  "interpreted relative to the already-running script's directory."
5191
5190
  )
5192
5191
 
5193
- relative_run_script_epilog = "Notes:\n" " This command is intended to only be used within text file scripts."
5192
+ relative_run_script_epilog = "Notes:\n This command is intended to only be used within text file scripts."
5194
5193
 
5195
5194
  relative_run_script_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
5196
5195
  description=relative_run_script_description, epilog=relative_run_script_epilog
@@ -5516,9 +5515,9 @@ class Cmd(cmd.Cmd):
5516
5515
  """
5517
5516
  Report when a disabled command has been run or had help called on it
5518
5517
 
5519
- :param args: not used
5518
+ :param _args: not used
5520
5519
  :param message_to_print: the message reporting that the command is disabled
5521
- :param kwargs: not used
5520
+ :param _kwargs: not used
5522
5521
  """
5523
5522
  # Set apply_style to False so message_to_print's style is not overridden
5524
5523
  self.perror(message_to_print, apply_style=False)
@@ -5672,7 +5671,7 @@ class Cmd(cmd.Cmd):
5672
5671
  raise TypeError(f'{func.__name__} does not have a declared return type, expected {data_type}')
5673
5672
  if signature.return_annotation != data_type:
5674
5673
  raise TypeError(
5675
- f'{func.__name__} has incompatible return type {signature.return_annotation}, expected ' f'{data_type}'
5674
+ f'{func.__name__} has incompatible return type {signature.return_annotation}, expected {data_type}'
5676
5675
  )
5677
5676
 
5678
5677
  def register_precmd_hook(self, func: Callable[[plugin.PrecommandData], plugin.PrecommandData]) -> None:
@@ -114,7 +114,7 @@ class CommandSet(object):
114
114
  Override this property if you need to change its return type to a
115
115
  child class of Cmd.
116
116
 
117
- :raises: CommandSetRegistrationError if CommandSet is not registered.
117
+ :raises CommandSetRegistrationError: if CommandSet is not registered.
118
118
  """
119
119
  if self.__cmd_internal is None:
120
120
  raise CommandSetRegistrationError('This CommandSet is not registered')
@@ -127,7 +127,7 @@ class CommandSet(object):
127
127
  requiring access to the Cmd object (e.g. configure commands and their parsers based on CLI state data).
128
128
 
129
129
  :param cmd: The cmd2 main application
130
- :raises: CommandSetRegistrationError if CommandSet is already registered.
130
+ :raises CommandSetRegistrationError: if CommandSet is already registered.
131
131
  """
132
132
  if self.__cmd_internal is None:
133
133
  self.__cmd_internal = cmd
@@ -185,7 +185,7 @@ class CommandSet(object):
185
185
  Convenience method for removing a settable parameter from the CommandSet
186
186
 
187
187
  :param name: name of the settable being removed
188
- :raises: KeyError if the Settable matches this name
188
+ :raises KeyError: if the Settable matches this name
189
189
  """
190
190
  try:
191
191
  del self._settables[name]
cmd2/decorators.py CHANGED
@@ -43,15 +43,17 @@ def with_category(category: str) -> Callable[[CommandFunc], CommandFunc]:
43
43
  :param category: the name of the category in which this command should
44
44
  be grouped when displaying the list of commands.
45
45
 
46
- :Example:
46
+ Example:
47
47
 
48
- >>> class MyApp(cmd2.Cmd):
49
- >>> @cmd2.with_category('Text Functions')
50
- >>> def do_echo(self, args)
51
- >>> self.poutput(args)
48
+ ```py
49
+ class MyApp(cmd2.Cmd):
50
+ @cmd2.with_category('Text Functions')
51
+ def do_echo(self, args)
52
+ self.poutput(args)
53
+ ```
52
54
 
53
55
  For an alternative approach to categorizing commands using a function, see
54
- :func:`~cmd2.utils.categorize`
56
+ [cmd2.utils.categorize][]
55
57
  """
56
58
 
57
59
  def cat_decorator(func: CommandFunc) -> CommandFunc:
@@ -89,7 +91,7 @@ def _parse_positionals(args: Tuple[Any, ...]) -> Tuple['cmd2.Cmd', Union[Stateme
89
91
  Cmd,
90
92
  )
91
93
 
92
- if (isinstance(arg, Cmd) or isinstance(arg, CommandSet)) and len(args) > pos:
94
+ if isinstance(arg, (Cmd, CommandSet)) and len(args) > pos + 1:
93
95
  if isinstance(arg, CommandSet):
94
96
  arg = arg._cmd
95
97
  next_arg = args[pos + 1]
@@ -98,7 +100,7 @@ def _parse_positionals(args: Tuple[Any, ...]) -> Tuple['cmd2.Cmd', Union[Stateme
98
100
 
99
101
  # This shouldn't happen unless we forget to pass statement in `Cmd.onecmd` or
100
102
  # somehow call the unbound class method.
101
- raise TypeError('Expected arguments: cmd: cmd2.Cmd, statement: Union[Statement, str] Not found') # pragma: no cover
103
+ raise TypeError('Expected arguments: cmd: cmd2.Cmd, statement: Union[Statement, str] Not found')
102
104
 
103
105
 
104
106
  def _arg_swap(args: Union[Sequence[Any]], search_arg: Any, *replace_arg: Any) -> List[Any]:
@@ -116,17 +118,17 @@ def _arg_swap(args: Union[Sequence[Any]], search_arg: Any, *replace_arg: Any) ->
116
118
  return args_list
117
119
 
118
120
 
119
- #: Function signature for an Command Function that accepts a pre-processed argument list from user input
121
+ #: Function signature for a command function that accepts a pre-processed argument list from user input
120
122
  #: and optionally returns a boolean
121
123
  ArgListCommandFuncOptionalBoolReturn = Callable[[CommandParent, List[str]], Optional[bool]]
122
- #: Function signature for an Command Function that accepts a pre-processed argument list from user input
124
+ #: Function signature for a command function that accepts a pre-processed argument list from user input
123
125
  #: and returns a boolean
124
126
  ArgListCommandFuncBoolReturn = Callable[[CommandParent, List[str]], bool]
125
- #: Function signature for an Command Function that accepts a pre-processed argument list from user input
127
+ #: Function signature for a command function that accepts a pre-processed argument list from user input
126
128
  #: and returns Nothing
127
129
  ArgListCommandFuncNoneReturn = Callable[[CommandParent, List[str]], None]
128
130
 
129
- #: Aggregate of all accepted function signatures for Command Functions that accept a pre-processed argument list
131
+ #: Aggregate of all accepted function signatures for command functions that accept a pre-processed argument list
130
132
  ArgListCommandFunc = Union[
131
133
  ArgListCommandFuncOptionalBoolReturn[CommandParent],
132
134
  ArgListCommandFuncBoolReturn[CommandParent],
@@ -152,12 +154,13 @@ def with_argument_list(
152
154
  :param preserve_quotes: if ``True``, then argument quotes will not be stripped
153
155
  :return: function that gets passed a list of argument strings
154
156
 
155
- :Example:
156
-
157
- >>> class MyApp(cmd2.Cmd):
158
- >>> @cmd2.with_argument_list
159
- >>> def do_echo(self, arglist):
160
- >>> self.poutput(' '.join(arglist)
157
+ Example:
158
+ ```py
159
+ class MyApp(cmd2.Cmd):
160
+ @cmd2.with_argument_list
161
+ def do_echo(self, arglist):
162
+ self.poutput(' '.join(arglist)
163
+ ```
161
164
  """
162
165
  import functools
163
166
 
@@ -246,21 +249,29 @@ def _set_parser_prog(parser: argparse.ArgumentParser, prog: str) -> None:
246
249
  req_args.append(action.dest)
247
250
 
248
251
 
249
- #: Function signature for a Command Function that uses an argparse.ArgumentParser to process user input
250
- #: and optionally returns a boolean
252
+ #: Function signatures for command functions that use an argparse.ArgumentParser to process user input
253
+ #: and optionally return a boolean
251
254
  ArgparseCommandFuncOptionalBoolReturn = Callable[[CommandParent, argparse.Namespace], Optional[bool]]
252
- #: Function signature for a Command Function that uses an argparse.ArgumentParser to process user input
253
- #: and returns a boolean
255
+ ArgparseCommandFuncWithUnknownArgsOptionalBoolReturn = Callable[[CommandParent, argparse.Namespace, List[str]], Optional[bool]]
256
+
257
+ #: Function signatures for command functions that use an argparse.ArgumentParser to process user input
258
+ #: and return a boolean
254
259
  ArgparseCommandFuncBoolReturn = Callable[[CommandParent, argparse.Namespace], bool]
255
- #: Function signature for an Command Function that uses an argparse.ArgumentParser to process user input
256
- #: and returns nothing
260
+ ArgparseCommandFuncWithUnknownArgsBoolReturn = Callable[[CommandParent, argparse.Namespace, List[str]], bool]
261
+
262
+ #: Function signatures for command functions that use an argparse.ArgumentParser to process user input
263
+ #: and return nothing
257
264
  ArgparseCommandFuncNoneReturn = Callable[[CommandParent, argparse.Namespace], None]
265
+ ArgparseCommandFuncWithUnknownArgsNoneReturn = Callable[[CommandParent, argparse.Namespace, List[str]], None]
258
266
 
259
- #: Aggregate of all accepted function signatures for an argparse Command Function
267
+ #: Aggregate of all accepted function signatures for an argparse command function
260
268
  ArgparseCommandFunc = Union[
261
269
  ArgparseCommandFuncOptionalBoolReturn[CommandParent],
270
+ ArgparseCommandFuncWithUnknownArgsOptionalBoolReturn[CommandParent],
262
271
  ArgparseCommandFuncBoolReturn[CommandParent],
272
+ ArgparseCommandFuncWithUnknownArgsBoolReturn[CommandParent],
263
273
  ArgparseCommandFuncNoneReturn[CommandParent],
274
+ ArgparseCommandFuncWithUnknownArgsNoneReturn[CommandParent],
264
275
  ]
265
276
 
266
277
 
@@ -285,38 +296,41 @@ def with_argparser(
285
296
  :param preserve_quotes: if ``True``, then arguments passed to argparse maintain their quotes
286
297
  :param with_unknown_args: if true, then capture unknown args
287
298
  :return: function that gets passed argparse-parsed args in a ``Namespace``
288
- A :class:`cmd2.argparse_custom.Cmd2AttributeWrapper` called ``cmd2_statement`` is included
289
- in the ``Namespace`` to provide access to the :class:`cmd2.Statement` object that was created when
299
+ A [cmd2.argparse_custom.Cmd2AttributeWrapper][] called ``cmd2_statement`` is included
300
+ in the ``Namespace`` to provide access to the [cmd2.Statement][] object that was created when
290
301
  parsing the command line. This can be useful if the command function needs to know the command line.
291
302
 
292
- :Example:
293
-
294
- >>> parser = cmd2.Cmd2ArgumentParser()
295
- >>> parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
296
- >>> parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
297
- >>> parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
298
- >>> parser.add_argument('words', nargs='+', help='words to print')
299
- >>>
300
- >>> class MyApp(cmd2.Cmd):
301
- >>> @cmd2.with_argparser(parser, preserve_quotes=True)
302
- >>> def do_argprint(self, args):
303
- >>> "Print the options and argument list this options command was called with."
304
- >>> self.poutput(f'args: {args!r}')
305
-
306
- :Example with unknown args:
307
-
308
- >>> parser = cmd2.Cmd2ArgumentParser()
309
- >>> parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
310
- >>> parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
311
- >>> parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
312
- >>>
313
- >>> class MyApp(cmd2.Cmd):
314
- >>> @cmd2.with_argparser(parser, with_unknown_args=True)
315
- >>> def do_argprint(self, args, unknown):
316
- >>> "Print the options and argument list this options command was called with."
317
- >>> self.poutput(f'args: {args!r}')
318
- >>> self.poutput(f'unknowns: {unknown}')
319
-
303
+ Example:
304
+
305
+ ```py
306
+ parser = cmd2.Cmd2ArgumentParser()
307
+ parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
308
+ parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
309
+ parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
310
+ parser.add_argument('words', nargs='+', help='words to print')
311
+
312
+ class MyApp(cmd2.Cmd):
313
+ @cmd2.with_argparser(parser, preserve_quotes=True)
314
+ def do_argprint(self, args):
315
+ "Print the options and argument list this options command was called with."
316
+ self.poutput(f'args: {args!r}')
317
+ ```
318
+
319
+ Example with unknown args:
320
+
321
+ ```py
322
+ parser = cmd2.Cmd2ArgumentParser()
323
+ parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
324
+ parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
325
+ parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
326
+
327
+ class MyApp(cmd2.Cmd):
328
+ @cmd2.with_argparser(parser, with_unknown_args=True)
329
+ def do_argprint(self, args, unknown):
330
+ "Print the options and argument list this options command was called with."
331
+ self.poutput(f'args: {args!r}')
332
+ self.poutput(f'unknowns: {unknown}')
333
+ ```
320
334
  """
321
335
  import functools
322
336
 
@@ -340,7 +354,7 @@ def with_argparser(
340
354
  contiguously somewhere in the list
341
355
  :param kwargs: any keyword arguments being passed to command function
342
356
  :return: return value of command function
343
- :raises: Cmd2ArgparseError if argparse has error parsing command line
357
+ :raises Cmd2ArgparseError: if argparse has error parsing command line
344
358
  """
345
359
  cmd2_app, statement_arg = _parse_positionals(args)
346
360
  statement, parsed_arglist = cmd2_app.statement_parser.get_command_arg_list(
cmd2/history.py CHANGED
@@ -150,13 +150,13 @@ class HistoryItem:
150
150
 
151
151
 
152
152
  class History(List[HistoryItem]):
153
- """A list of :class:`~cmd2.history.HistoryItem` objects with additional methods
153
+ """A list of [HistoryItem][cmd2.history.HistoryItem] objects with additional methods
154
154
  for searching and managing the list.
155
155
 
156
- :class:`~cmd2.Cmd` instantiates this class into the :data:`~cmd2.Cmd.history`
156
+ [cmd2.Cmd][] instantiates this class into the `cmd2.Cmd.history`
157
157
  attribute, and adds commands to it as a user enters them.
158
158
 
159
- See :ref:`features/history:History` for information about the built-in command
159
+ See [History](../features/history.md) for information about the built-in command
160
160
  which allows users to view, search, run, and save previously entered commands.
161
161
 
162
162
  Developers interested in accessing previously entered commands can use this
@@ -207,7 +207,7 @@ class History(List[HistoryItem]):
207
207
  """Get item from the History list using 1-based indexing.
208
208
 
209
209
  :param index: optional item to get
210
- :return: a single :class:`~cmd2.history.HistoryItem`
210
+ :return: a single [cmd2.history.HistoryItem][]
211
211
  """
212
212
  if index == 0:
213
213
  raise IndexError('The first command in history is command 1.')
cmd2/parsing.py CHANGED
@@ -98,7 +98,7 @@ class Statement(str): # type: ignore[override]
98
98
  we add our own attributes to this subclass.
99
99
 
100
100
  Instances of this class should not be created by anything other than the
101
- :meth:`cmd2.parsing.StatementParser.parse` method, nor should any of the
101
+ [StatementParser.parse][cmd2.parsing.StatementParser.parse] method, nor should any of the
102
102
  attributes be modified once the object is created.
103
103
 
104
104
  The string portion of the class contains the arguments, but not the
@@ -108,15 +108,15 @@ class Statement(str): # type: ignore[override]
108
108
 
109
109
  1. `argparse <https://docs.python.org/3/library/argparse.html>`_ is your
110
110
  friend for anything complex. ``cmd2`` has the decorator
111
- (:func:`~cmd2.decorators.with_argparser`) which you can
111
+ ([cmd2.decorators.with_argparser][]) which you can
112
112
  use to make your command method receive a namespace of parsed arguments,
113
113
  whether positional or denoted with switches.
114
114
 
115
115
  2. For commands with simple positional arguments, use
116
- :attr:`~cmd2.Statement.args` or :attr:`~cmd2.Statement.arg_list`
116
+ [args][cmd2.Statement.args] or [arg_list][cmd2.Statement.arg_list]
117
117
 
118
118
  3. If you don't want to have to worry about quoted arguments, see
119
- :attr:`argv` for a trick which strips quotes off for you.
119
+ [argv][cmd2.Statement.argv] for a trick which strips quotes off for you.
120
120
  """
121
121
 
122
122
  # the arguments, but not the command, nor the output redirection clauses.
@@ -202,8 +202,7 @@ class Statement(str): # type: ignore[override]
202
202
 
203
203
  @property
204
204
  def expanded_command_line(self) -> str:
205
- """Concatenate :meth:`~cmd2.Statement.command_and_args`
206
- and :meth:`~cmd2.Statement.post_command`"""
205
+ """Concatenate [command_and_args][cmd2.Statement.command_and_args] and [post_command][cmd2.Statement.post_command]"""
207
206
  return self.command_and_args + self.post_command
208
207
 
209
208
  @property
@@ -377,7 +376,7 @@ class StatementParser:
377
376
 
378
377
  :param line: the command line being lexed
379
378
  :return: A list of tokens
380
- :raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
379
+ :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
381
380
  """
382
381
 
383
382
  # expand shortcuts and aliases
@@ -399,13 +398,13 @@ class StatementParser:
399
398
 
400
399
  def parse(self, line: str) -> Statement:
401
400
  """
402
- Tokenize the input and parse it into a :class:`~cmd2.Statement` object,
401
+ Tokenize the input and parse it into a [cmd2.parsing.Statement][] object,
403
402
  stripping comments, expanding aliases and shortcuts, and extracting output
404
403
  redirection directives.
405
404
 
406
405
  :param line: the command line being parsed
407
- :return: a new :class:`~cmd2.Statement` object
408
- :raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
406
+ :return: a new [cmd2.parsing.Statement][] object
407
+ :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
409
408
  """
410
409
 
411
410
  # handle the special case/hardcoded terminator of a blank line
@@ -544,7 +543,7 @@ class StatementParser:
544
543
  return statement
545
544
 
546
545
  def parse_command_only(self, rawinput: str) -> Statement:
547
- """Partially parse input into a :class:`~cmd2.Statement` object.
546
+ """Partially parse input into a [cmd2.Statement][] object.
548
547
 
549
548
  The command is identified, and shortcuts and aliases are expanded.
550
549
  Multiline commands are identified, but terminators and output
@@ -553,21 +552,21 @@ class StatementParser:
553
552
  This method is used by tab completion code and therefore must not
554
553
  generate an exception if there are unclosed quotes.
555
554
 
556
- The :class:`~cmd2.Statement` object returned by this method can at most
555
+ The [cmd2.parsing.Statement][] object returned by this method can at most
557
556
  contain values in the following attributes:
558
- :attr:`~cmd2.Statement.args`, :attr:`~cmd2.Statement.raw`,
559
- :attr:`~cmd2.Statement.command`,
560
- :attr:`~cmd2.Statement.multiline_command`
557
+ [cmd2.parsing.Statement.args][], [cmd2.parsing.Statement.raw][],
558
+ [cmd2.parsing.Statement.command][],
559
+ [cmd2.parsing.Statement.multiline_command][]
561
560
 
562
- :attr:`~cmd2.Statement.args` will include all output redirection
561
+ [cmd2.parsing.Statement.args][] will include all output redirection
563
562
  clauses and command terminators.
564
563
 
565
- Different from :meth:`~cmd2.parsing.StatementParser.parse` this method
564
+ Different from [cmd2.parsing.StatementParser.parse][] this method
566
565
  does not remove redundant whitespace within args. However, it does
567
566
  ensure args has no leading or trailing whitespace.
568
567
 
569
568
  :param rawinput: the command line as entered by the user
570
- :return: a new :class:`~cmd2.Statement` object
569
+ :return: a new [cmd2.Statement][] object
571
570
  """
572
571
  # expand shortcuts and aliases
573
572
  line = self._expand(rawinput)
@@ -617,18 +616,18 @@ class StatementParser:
617
616
  :param command_name: name of the command being run
618
617
  :param to_parse: what is being passed to the ``do_*`` method. It can be one of two types:
619
618
 
620
- 1. An already parsed :class:`~cmd2.Statement`
619
+ 1. An already parsed [cmd2.Statement][]
621
620
  2. An argument string in cases where a ``do_*`` method is
622
621
  explicitly called. Calling ``do_help('alias create')`` would
623
622
  cause ``to_parse`` to be 'alias create'.
624
623
 
625
624
  In this case, the string will be converted to a
626
- :class:`~cmd2.Statement` and returned along with
625
+ [cmd2.Statement][] and returned along with
627
626
  the argument list.
628
627
 
629
628
  :param preserve_quotes: if ``True``, then quotes will not be stripped from
630
629
  the arguments
631
- :return: A tuple containing the :class:`~cmd2.Statement` and a list of
630
+ :return: A tuple containing the [cmd2.Statement][] and a list of
632
631
  strings representing the arguments
633
632
  """
634
633
  # Check if to_parse needs to be converted to a Statement
cmd2/py_bridge.py CHANGED
@@ -57,7 +57,7 @@ class CommandResult(NamedTuple):
57
57
  if isinstance(sys.stderr, StdSim):
58
58
  sys.stderr.pause_storage = True
59
59
 
60
- See :class:`~cmd2.utils.StdSim` for more information.
60
+ See [cmd2.utils.StdSim][] for more information.
61
61
 
62
62
  .. note::
63
63
 
cmd2/table_creator.py CHANGED
@@ -92,8 +92,8 @@ class Column:
92
92
  (defaults to True)
93
93
  :param max_data_lines: maximum lines allowed in a data cell. If line count exceeds this, then the final
94
94
  line displayed will be truncated with an ellipsis. (defaults to INFINITY)
95
- :raises: ValueError if width is less than 1
96
- :raises: ValueError if max_data_lines is less than 1
95
+ :raises ValueError: if width is less than 1
96
+ :raises ValueError: if max_data_lines is less than 1
97
97
  """
98
98
  self.header = header
99
99
 
@@ -138,7 +138,7 @@ class TableCreator:
138
138
  :param cols: column definitions for this table
139
139
  :param tab_width: all tabs will be replaced with this many spaces. If a row's fill_char is a tab,
140
140
  then it will be converted to one space.
141
- :raises: ValueError if tab_width is less than 1
141
+ :raises ValueError: if tab_width is less than 1
142
142
  """
143
143
  if tab_width < 1:
144
144
  raise ValueError("Tab width cannot be less than 1")
@@ -443,9 +443,9 @@ class TableCreator:
443
443
  :param post_line: string to print after each line of a row. This can be used for padding after
444
444
  the last cell's text and a right row border. (Defaults to blank)
445
445
  :return: row string
446
- :raises: ValueError if row_data isn't the same length as self.cols
447
- :raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
448
- :raises: ValueError if fill_char, pre_line, inter_cell, or post_line contains an unprintable
446
+ :raises ValueError: if row_data isn't the same length as self.cols
447
+ :raises TypeError: if fill_char is more than one character (not including ANSI style sequences)
448
+ :raises ValueError: if fill_char, pre_line, inter_cell, or post_line contains an unprintable
449
449
  character like a newline
450
450
  """
451
451
 
@@ -570,10 +570,10 @@ class SimpleTable(TableCreator):
570
570
  want a divider row. Defaults to dash. (Cannot be a line breaking character)
571
571
  :param header_bg: optional background color for header cells (defaults to None)
572
572
  :param data_bg: optional background color for data cells (defaults to None)
573
- :raises: ValueError if tab_width is less than 1
574
- :raises: ValueError if column_spacing is less than 0
575
- :raises: TypeError if divider_char is longer than one character
576
- :raises: ValueError if divider_char is an unprintable character
573
+ :raises ValueError: if tab_width is less than 1
574
+ :raises ValueError: if column_spacing is less than 0
575
+ :raises TypeError: if divider_char is longer than one character
576
+ :raises ValueError: if divider_char is an unprintable character
577
577
  """
578
578
  super().__init__(cols, tab_width=tab_width)
579
579
 
@@ -626,8 +626,8 @@ class SimpleTable(TableCreator):
626
626
  :param num_cols: how many columns the table will have
627
627
  :param column_spacing: how many spaces to place between columns. Defaults to 2.
628
628
  :return: base width
629
- :raises: ValueError if column_spacing is less than 0
630
- :raises: ValueError if num_cols is less than 1
629
+ :raises ValueError: if column_spacing is less than 0
630
+ :raises ValueError: if num_cols is less than 1
631
631
  """
632
632
  if num_cols < 1:
633
633
  raise ValueError("Column count cannot be less than 1")
@@ -685,7 +685,7 @@ class SimpleTable(TableCreator):
685
685
 
686
686
  :param row_data: data with an entry for each column in the row
687
687
  :return: data row string
688
- :raises: ValueError if row_data isn't the same length as self.cols
688
+ :raises ValueError: if row_data isn't the same length as self.cols
689
689
  """
690
690
  if len(row_data) != len(self.cols):
691
691
  raise ValueError("Length of row_data must match length of cols")
@@ -712,7 +712,7 @@ class SimpleTable(TableCreator):
712
712
  :param include_header: If True, then a header will be included at top of table. (Defaults to True)
713
713
  :param row_spacing: A number 0 or greater specifying how many blank lines to place between
714
714
  each row (Defaults to 1)
715
- :raises: ValueError if row_spacing is less than 0
715
+ :raises ValueError: if row_spacing is less than 0
716
716
  """
717
717
  if row_spacing < 0:
718
718
  raise ValueError("Row spacing cannot be less than 0")
@@ -771,8 +771,8 @@ class BorderedTable(TableCreator):
771
771
  :param border_bg: optional background color for borders (defaults to None)
772
772
  :param header_bg: optional background color for header cells (defaults to None)
773
773
  :param data_bg: optional background color for data cells (defaults to None)
774
- :raises: ValueError if tab_width is less than 1
775
- :raises: ValueError if padding is less than 0
774
+ :raises ValueError: if tab_width is less than 1
775
+ :raises ValueError: if padding is less than 0
776
776
  """
777
777
  super().__init__(cols, tab_width=tab_width)
778
778
  self.empty_data = [EMPTY] * len(self.cols)
@@ -827,7 +827,7 @@ class BorderedTable(TableCreator):
827
827
  :param column_borders: if True, borders between columns will be included in the calculation (Defaults to True)
828
828
  :param padding: number of spaces between text and left/right borders of cell
829
829
  :return: base width
830
- :raises: ValueError if num_cols is less than 1
830
+ :raises ValueError: if num_cols is less than 1
831
831
  """
832
832
  if num_cols < 1:
833
833
  raise ValueError("Column count cannot be less than 1")
@@ -976,7 +976,7 @@ class BorderedTable(TableCreator):
976
976
 
977
977
  :param row_data: data with an entry for each column in the row
978
978
  :return: data row string
979
- :raises: ValueError if row_data isn't the same length as self.cols
979
+ :raises ValueError: if row_data isn't the same length as self.cols
980
980
  """
981
981
  if len(row_data) != len(self.cols):
982
982
  raise ValueError("Length of row_data must match length of cols")
@@ -1077,8 +1077,8 @@ class AlternatingTable(BorderedTable):
1077
1077
  :param header_bg: optional background color for header cells (defaults to None)
1078
1078
  :param odd_bg: optional background color for odd numbered data rows (defaults to None)
1079
1079
  :param even_bg: optional background color for even numbered data rows (defaults to StdBg.DARK_GRAY)
1080
- :raises: ValueError if tab_width is less than 1
1081
- :raises: ValueError if padding is less than 0
1080
+ :raises ValueError: if tab_width is less than 1
1081
+ :raises ValueError: if padding is less than 0
1082
1082
  """
1083
1083
  super().__init__(
1084
1084
  cols,
cmd2/utils.py CHANGED
@@ -101,7 +101,7 @@ def to_bool(val: Any) -> bool:
101
101
 
102
102
  :param val: value being converted
103
103
  :return: boolean value expressed in the passed in value
104
- :raises: ValueError if the string does not contain a value corresponding to a boolean value
104
+ :raises ValueError: if the string does not contain a value corresponding to a boolean value
105
105
  """
106
106
  if isinstance(val, str):
107
107
  if val.capitalize() == str(True):
@@ -209,7 +209,7 @@ def is_text_file(file_path: str) -> bool:
209
209
 
210
210
  :param file_path: path to the file being checked
211
211
  :return: True if the file is a non-empty text file, otherwise False
212
- :raises OSError if file can't be read
212
+ :raises OSError: if file can't be read
213
213
  """
214
214
  import codecs
215
215
 
@@ -858,9 +858,9 @@ def align_text(
858
858
  :param truncate: if True, then each line will be shortened to fit within the display width. The truncated
859
859
  portions are replaced by a '…' character. Defaults to False.
860
860
  :return: aligned text
861
- :raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
862
- :raises: ValueError if text or fill_char contains an unprintable character
863
- :raises: ValueError if width is less than 1
861
+ :raises TypeError: if fill_char is more than one character (not including ANSI style sequences)
862
+ :raises ValueError: if text or fill_char contains an unprintable character
863
+ :raises ValueError: if width is less than 1
864
864
  """
865
865
  import io
866
866
  import shutil
@@ -982,9 +982,9 @@ def align_left(
982
982
  :param truncate: if True, then text will be shortened to fit within the display width. The truncated portion is
983
983
  replaced by a '…' character. Defaults to False.
984
984
  :return: left-aligned text
985
- :raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
986
- :raises: ValueError if text or fill_char contains an unprintable character
987
- :raises: ValueError if width is less than 1
985
+ :raises TypeError: if fill_char is more than one character (not including ANSI style sequences)
986
+ :raises ValueError: if text or fill_char contains an unprintable character
987
+ :raises ValueError: if width is less than 1
988
988
  """
989
989
  return align_text(text, TextAlignment.LEFT, fill_char=fill_char, width=width, tab_width=tab_width, truncate=truncate)
990
990
 
@@ -1005,9 +1005,9 @@ def align_center(
1005
1005
  :param truncate: if True, then text will be shortened to fit within the display width. The truncated portion is
1006
1006
  replaced by a '…' character. Defaults to False.
1007
1007
  :return: centered text
1008
- :raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
1009
- :raises: ValueError if text or fill_char contains an unprintable character
1010
- :raises: ValueError if width is less than 1
1008
+ :raises TypeError: if fill_char is more than one character (not including ANSI style sequences)
1009
+ :raises ValueError: if text or fill_char contains an unprintable character
1010
+ :raises ValueError: if width is less than 1
1011
1011
  """
1012
1012
  return align_text(text, TextAlignment.CENTER, fill_char=fill_char, width=width, tab_width=tab_width, truncate=truncate)
1013
1013
 
@@ -1028,9 +1028,9 @@ def align_right(
1028
1028
  :param truncate: if True, then text will be shortened to fit within the display width. The truncated portion is
1029
1029
  replaced by a '…' character. Defaults to False.
1030
1030
  :return: right-aligned text
1031
- :raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
1032
- :raises: ValueError if text or fill_char contains an unprintable character
1033
- :raises: ValueError if width is less than 1
1031
+ :raises TypeError: if fill_char is more than one character (not including ANSI style sequences)
1032
+ :raises ValueError: if text or fill_char contains an unprintable character
1033
+ :raises ValueError: if width is less than 1
1034
1034
  """
1035
1035
  return align_text(text, TextAlignment.RIGHT, fill_char=fill_char, width=width, tab_width=tab_width, truncate=truncate)
1036
1036
 
@@ -1053,8 +1053,8 @@ def truncate_line(line: str, max_width: int, *, tab_width: int = 4) -> str:
1053
1053
  :param max_width: the maximum display width the resulting string is allowed to have
1054
1054
  :param tab_width: any tabs in the text will be replaced with this many spaces
1055
1055
  :return: line that has a display width less than or equal to width
1056
- :raises: ValueError if text contains an unprintable character like a newline
1057
- :raises: ValueError if max_width is less than 1
1056
+ :raises ValueError: if text contains an unprintable character like a newline
1057
+ :raises ValueError: if max_width is less than 1
1058
1058
  """
1059
1059
  import io
1060
1060
 
@@ -1152,17 +1152,18 @@ def categorize(func: Union[Callable[..., Any], Iterable[Callable[..., Any]]], ca
1152
1152
  :param func: function or list of functions to categorize
1153
1153
  :param category: category to put it in
1154
1154
 
1155
- :Example:
1155
+ Example:
1156
1156
 
1157
- >>> import cmd2
1158
- >>> class MyApp(cmd2.Cmd):
1159
- >>> def do_echo(self, arglist):
1160
- >>> self.poutput(' '.join(arglist)
1161
- >>>
1162
- >>> cmd2.utils.categorize(do_echo, "Text Processing")
1157
+ ```py
1158
+ import cmd2
1159
+ class MyApp(cmd2.Cmd):
1160
+ def do_echo(self, arglist):
1161
+ self.poutput(' '.join(arglist)
1163
1162
 
1164
- For an alternative approach to categorizing commands using a decorator, see
1165
- :func:`~cmd2.decorators.with_category`
1163
+ cmd2.utils.categorize(do_echo, "Text Processing")
1164
+ ```
1165
+
1166
+ For an alternative approach to categorizing commands using a decorator, see [cmd2.decorators.with_category][]
1166
1167
  """
1167
1168
  if isinstance(func, Iterable):
1168
1169
  for item in func:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: cmd2
3
- Version: 2.5.8
3
+ Version: 2.5.10
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)
@@ -43,43 +43,10 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
43
43
  Requires-Python: >=3.8
44
44
  Description-Content-Type: text/markdown
45
45
  License-File: LICENSE
46
- Requires-Dist: gnureadline; platform_system == "Darwin"
47
- Requires-Dist: pyperclip
48
- Requires-Dist: pyreadline3; platform_system == "Windows"
49
- Requires-Dist: wcwidth
50
- Provides-Extra: build
51
- Requires-Dist: build; extra == "build"
52
- Requires-Dist: setuptools; extra == "build"
53
- Requires-Dist: setuptools-scm; extra == "build"
54
- Provides-Extra: dev
55
- Requires-Dist: codecov; extra == "dev"
56
- Requires-Dist: doc8; extra == "dev"
57
- Requires-Dist: invoke; extra == "dev"
58
- Requires-Dist: mypy; extra == "dev"
59
- Requires-Dist: pytest; extra == "dev"
60
- Requires-Dist: pytest-cov; extra == "dev"
61
- Requires-Dist: pytest-mock; extra == "dev"
62
- Requires-Dist: sphinx; extra == "dev"
63
- Requires-Dist: sphinx-autobuild; extra == "dev"
64
- Requires-Dist: sphinx-rtd-theme; extra == "dev"
65
- Requires-Dist: ruff; extra == "dev"
66
- Requires-Dist: twine; extra == "dev"
67
- Provides-Extra: docs
68
- Requires-Dist: setuptools; extra == "docs"
69
- Requires-Dist: setuptools_scm; extra == "docs"
70
- Requires-Dist: sphinx; extra == "docs"
71
- Requires-Dist: sphinx-autobuild; extra == "docs"
72
- Requires-Dist: sphinx-rtd-theme; extra == "docs"
73
- Provides-Extra: test
74
- Requires-Dist: codecov; extra == "test"
75
- Requires-Dist: coverage; extra == "test"
76
- Requires-Dist: pytest; extra == "test"
77
- Requires-Dist: pytest-cov; extra == "test"
78
- Requires-Dist: pytest-mock; extra == "test"
79
- Provides-Extra: validate
80
- Requires-Dist: mypy; extra == "validate"
81
- Requires-Dist: ruff; extra == "validate"
82
- Requires-Dist: types-setuptools; extra == "validate"
46
+ Requires-Dist: gnureadline>=8; platform_system == "Darwin"
47
+ Requires-Dist: pyperclip>=1.8
48
+ Requires-Dist: pyreadline3>=3.4; platform_system == "Windows"
49
+ Requires-Dist: wcwidth>=0.2.10
83
50
 
84
51
  <h1 align="center">cmd2 : immersive interactive command line applications</h1>
85
52
 
@@ -172,13 +139,16 @@ The best way to learn the cmd2 api is to delve into the example applications loc
172
139
  ## Tutorials
173
140
 
174
141
  - PyOhio 2019 presentation:
175
- - [video](https://www.youtube.com/watch?v=pebeWrTqIIw)
176
- - [slides](https://github.com/python-cmd2/talks/blob/master/PyOhio_2019/cmd2-PyOhio_2019.pdf)
177
- - [example code](https://github.com/python-cmd2/talks/tree/master/PyOhio_2019/examples)
142
+ - [video](https://www.youtube.com/watch?v=pebeWrTqIIw)
143
+ - [slides](https://github.com/python-cmd2/talks/blob/master/PyOhio_2019/cmd2-PyOhio_2019.pdf)
144
+ - [example code](https://github.com/python-cmd2/talks/tree/master/PyOhio_2019/examples)
178
145
  - [Cookiecutter](https://github.com/cookiecutter/cookiecutter) Templates from community
179
- - Basic cookiecutter template for cmd2 application : https://github.com/jayrod/cookiecutter-python-cmd2
180
- - Advanced cookiecutter template with external plugin support : https://github.com/jayrod/cookiecutter-python-cmd2-ext-plug
181
- - [Example Applications](https://github.com/jayrod/cmd2-example-apps)
146
+ - Basic cookiecutter template for cmd2 application : https://github.com/jayrod/cookiecutter-python-cmd2
147
+ - Advanced cookiecutter template with external plugin support : https://github.com/jayrod/cookiecutter-python-cmd2-ext-plug
148
+ - [cmd2 example applications](https://github.com/python-cmd2/cmd2/tree/master/examples)
149
+ - Basic cmd2 examples to demonstrate how to use various features
150
+ - [Advanced Examples](https://github.com/jayrod/cmd2-example-apps)
151
+ - More complex examples that demonstrate more featuers about how to put together a complete application
182
152
 
183
153
  ## Hello World
184
154
 
@@ -0,0 +1,24 @@
1
+ cmd2/__init__.py,sha256=C6IHJ_uHgkqejuRwA10IK0-OzPxHKyZbPn82nMUwn-A,2602
2
+ cmd2/ansi.py,sha256=nKpnciNvebb9FG0VLfs4yRfq9H49DI27flLoRBMscSo,32036
3
+ cmd2/argparse_completer.py,sha256=M2D1dnc-2SfjzPUUXpBUcD3EJpT34qSsk9ekQtQFOXs,36505
4
+ cmd2/argparse_custom.py,sha256=DqRehL5bEiz5FAQAa1aG2mj3vs91pgeYEtADo_NiEgE,57642
5
+ cmd2/clipboard.py,sha256=7EISono76d7djj17hbvR9cCTB7jVGSBkUjgVQiMyUjE,549
6
+ cmd2/cmd2.py,sha256=VWc-AN_3EYucH5WxrQZpJXxZmQNY25ORnueDhzGosVE,261112
7
+ cmd2/command_definition.py,sha256=g0BWrzQSOrWwvO1BbH5I8yNKNnvYLlXqL9ooKbDaUNY,7655
8
+ cmd2/constants.py,sha256=DioxETv-_HzcMUnjuPyz7Cqw4YEt_MTrzOMotiHj-Jo,1981
9
+ cmd2/decorators.py,sha256=agpCAUqeOhT0PFvYSJ7FNPcccZQntZLw2KAmLAF2AEY,20261
10
+ cmd2/exceptions.py,sha256=DwX7rQmon4eRyX1ZK4yne4lObdPO1j5Agg3Bav6pXwU,3600
11
+ cmd2/history.py,sha256=4iFi0Bny1CTjMx0ByQplrElvlZcus3lUgj2IyBfvAf0,14988
12
+ cmd2/parsing.py,sha256=uVWU_-WEZ_aow5IX9ktbVSE2WB_N86dY0D-GK8kzOhw,28297
13
+ cmd2/plugin.py,sha256=CCzzuHeBQbxH7YuG3UCdQ0uArnKYbodjhj-sYCbXSa0,814
14
+ cmd2/py.typed,sha256=qrkHrYJvGoZpU2BpVLNxJB44LlhqVSKyYOwD_L_1m3s,10
15
+ cmd2/py_bridge.py,sha256=DJCa7ff-XLwcz7Ij47nrwxgDDVUIVS5bRReLmayok1Q,5016
16
+ cmd2/rl_utils.py,sha256=HVPdNjuYyU67-XerPUJArmzhohzI1ABrZhU9cLc-EIs,11538
17
+ cmd2/table_creator.py,sha256=D9HgHaCu66ueCQRI7YIrdCX2g7Ow9hYN3Dj8gRJhXxs,47544
18
+ cmd2/transcript.py,sha256=I0sD38RbG79Qz9GXIlfh1pHSNmWBTY2SLZAKEdSLWI4,9182
19
+ cmd2/utils.py,sha256=50iSIHSenAmpBTefE0_32wT0CM9U5GdT5q4aX8mtzjM,49367
20
+ cmd2-2.5.10.dist-info/LICENSE,sha256=QXrW0Z0merk9mncyUkn-sgRxhT8_o1dL5HEaBNH47Q4,1099
21
+ cmd2-2.5.10.dist-info/METADATA,sha256=HrBCCwsip1J1m09TS9BXQfYrLTFTfX3PolKu3aaOwoM,17104
22
+ cmd2-2.5.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
23
+ cmd2-2.5.10.dist-info/top_level.txt,sha256=gJbOJmyrARwLhm5diXAtzlNQdxbDZ8iRJ8HJi65_5hg,5
24
+ cmd2-2.5.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,24 +0,0 @@
1
- cmd2/__init__.py,sha256=C6IHJ_uHgkqejuRwA10IK0-OzPxHKyZbPn82nMUwn-A,2602
2
- cmd2/ansi.py,sha256=DD1yVk4EnbKSmGM9Tj8jxWv23UZBVjbhdf0oOVhhl_c,32054
3
- cmd2/argparse_completer.py,sha256=6z0zmODqM7vhQhI0c6JUvCmR2V4qfdWQEyTZeNIea8c,36505
4
- cmd2/argparse_custom.py,sha256=bbAYRr79ZSJWGchd7trmRQDHWAsSJaW0dTQMp65Mrv4,57806
5
- cmd2/clipboard.py,sha256=7EISono76d7djj17hbvR9cCTB7jVGSBkUjgVQiMyUjE,549
6
- cmd2/cmd2.py,sha256=--45LzbUB5vLrrHYPV_pSQK3H9ePAacb4lBlXBQfB1A,261355
7
- cmd2/command_definition.py,sha256=OscFEk-O2N20fb8_fhkczqclaCxOwYyxNTnXWXOlngg,7655
8
- cmd2/constants.py,sha256=DioxETv-_HzcMUnjuPyz7Cqw4YEt_MTrzOMotiHj-Jo,1981
9
- cmd2/decorators.py,sha256=XXQKqei5CVM6k5zt8CdBmIDan-QwuN3YgJiaIsabbuA,19820
10
- cmd2/exceptions.py,sha256=DwX7rQmon4eRyX1ZK4yne4lObdPO1j5Agg3Bav6pXwU,3600
11
- cmd2/history.py,sha256=GkJ3pZQNGNoXa9pYLul_iaqLeK132V5nLZZG6MsIEus,15000
12
- cmd2/parsing.py,sha256=zWG_iDjUU6TWVNwMeY-yn6AIa2jx12Q9ey4DA9DGZFc,28272
13
- cmd2/plugin.py,sha256=CCzzuHeBQbxH7YuG3UCdQ0uArnKYbodjhj-sYCbXSa0,814
14
- cmd2/py.typed,sha256=qrkHrYJvGoZpU2BpVLNxJB44LlhqVSKyYOwD_L_1m3s,10
15
- cmd2/py_bridge.py,sha256=YUkEnng_kAwnFbh1sPMyeMya_BF7G1kg6MT-6mW-IG4,5022
16
- cmd2/rl_utils.py,sha256=HVPdNjuYyU67-XerPUJArmzhohzI1ABrZhU9cLc-EIs,11538
17
- cmd2/table_creator.py,sha256=qoxt9s3MxQkfSkp4cIPFMlVzC7kRjUU55p0ow7pFQus,47544
18
- cmd2/transcript.py,sha256=I0sD38RbG79Qz9GXIlfh1pHSNmWBTY2SLZAKEdSLWI4,9182
19
- cmd2/utils.py,sha256=4eBvbG6yqe3wg9wwi2jdng2iy5gghueNQjuF2afSyuI,49385
20
- cmd2-2.5.8.dist-info/LICENSE,sha256=QXrW0Z0merk9mncyUkn-sgRxhT8_o1dL5HEaBNH47Q4,1099
21
- cmd2-2.5.8.dist-info/METADATA,sha256=-y-uEodZc06B7Akuvlb5oRWVfaTmuUqjwJZ4kGuvR_I,18098
22
- cmd2-2.5.8.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
23
- cmd2-2.5.8.dist-info/top_level.txt,sha256=gJbOJmyrARwLhm5diXAtzlNQdxbDZ8iRJ8HJi65_5hg,5
24
- cmd2-2.5.8.dist-info/RECORD,,
File without changes