Skip to content

Commit 72fc6bf

Browse files
committed
Updated docs
1 parent a33da04 commit 72fc6bf

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

docs/features/modular_commands.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ You may need to disable command auto-loading if you need dynamically load comman
171171
self._fruits = LoadableFruits()
172172
self._vegetables = LoadableVegetables()
173173
174-
load_parser = cmd2.Cmd2ArgumentParser('load')
174+
load_parser = cmd2.Cmd2ArgumentParser()
175175
load_parser.add_argument('cmds', choices=['fruits', 'vegetables'])
176176
177177
@with_argparser(load_parser)
@@ -281,7 +281,7 @@ command and each CommandSet
281281
self._fruits = LoadableFruits()
282282
self._vegetables = LoadableVegetables()
283283
284-
load_parser = cmd2.Cmd2ArgumentParser('load')
284+
load_parser = cmd2.Cmd2ArgumentParser()
285285
load_parser.add_argument('cmds', choices=['fruits', 'vegetables'])
286286
287287
@with_argparser(load_parser)
@@ -311,8 +311,8 @@ command and each CommandSet
311311
self.unregister_command_set(self._vegetables)
312312
self.poutput('Vegetables unloaded')
313313
314-
cut_parser = cmd2.Cmd2ArgumentParser('cut')
315-
cut_subparsers = cut_parser.add_subparsers(title='item', help='item to cut', unloadable=True)
314+
cut_parser = cmd2.Cmd2ArgumentParser()
315+
cut_subparsers = cut_parser.add_subparsers(title='item', help='item to cut')
316316
317317
@with_argparser(cut_parser)
318318
def do_cut(self, ns: argparse.Namespace):

examples/modular_commands/commandset_complex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def do_banana(self, statement: cmd2.Statement):
2020
"""Banana Command"""
2121
self._cmd.poutput('Banana!!')
2222

23-
cranberry_parser = cmd2.Cmd2ArgumentParser('cranberry')
23+
cranberry_parser = cmd2.Cmd2ArgumentParser()
2424
cranberry_parser.add_argument('arg1', choices=['lemonade', 'juice', 'sauce'])
2525

2626
@cmd2.with_argparser(cranberry_parser, with_unknown_args=True)
@@ -44,7 +44,7 @@ def do_durian(self, args: List[str]):
4444
def complete_durian(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
4545
return utils.basic_complete(text, line, begidx, endidx, ['stinks', 'smells', 'disgusting'])
4646

47-
elderberry_parser = cmd2.Cmd2ArgumentParser('elderberry')
47+
elderberry_parser = cmd2.Cmd2ArgumentParser()
4848
elderberry_parser.add_argument('arg1')
4949

5050
@cmd2.with_category('Alone')

examples/modular_commands_dynamic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, *args, **kwargs):
5050
self._fruits = LoadableFruits()
5151
self._vegetables = LoadableVegetables()
5252

53-
load_parser = cmd2.Cmd2ArgumentParser('load')
53+
load_parser = cmd2.Cmd2ArgumentParser()
5454
load_parser.add_argument('cmds', choices=['fruits', 'vegetables'])
5555

5656
@with_argparser(load_parser)

examples/modular_subcommands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, *args, **kwargs):
6262
self._fruits = LoadableFruits()
6363
self._vegetables = LoadableVegetables()
6464

65-
load_parser = cmd2.Cmd2ArgumentParser('load')
65+
load_parser = cmd2.Cmd2ArgumentParser()
6666
load_parser.add_argument('cmds', choices=['fruits', 'vegetables'])
6767

6868
@with_argparser(load_parser)
@@ -92,7 +92,7 @@ def do_unload(self, ns: argparse.Namespace):
9292
self.unregister_command_set(self._vegetables)
9393
self.poutput('Vegetables unloaded')
9494

95-
cut_parser = cmd2.Cmd2ArgumentParser('cut')
95+
cut_parser = cmd2.Cmd2ArgumentParser()
9696
cut_subparsers = cut_parser.add_subparsers(title='item', help='item to cut')
9797

9898
@with_argparser(cut_parser)

tests_isolated/test_commandset/test_commandset.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def do_banana(self, statement: cmd2.Statement):
4040
"""Banana Command"""
4141
self._cmd.poutput('Banana!!')
4242

43-
cranberry_parser = cmd2.Cmd2ArgumentParser('cranberry')
43+
cranberry_parser = cmd2.Cmd2ArgumentParser()
4444
cranberry_parser.add_argument('arg1', choices=['lemonade', 'juice', 'sauce'])
4545

4646
@cmd2.with_argparser(cranberry_parser, with_unknown_args=True)
@@ -65,7 +65,7 @@ def do_durian(self, args: List[str]):
6565
def complete_durian(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
6666
return utils.basic_complete(text, line, begidx, endidx, ['stinks', 'smells', 'disgusting'])
6767

68-
elderberry_parser = cmd2.Cmd2ArgumentParser('elderberry')
68+
elderberry_parser = cmd2.Cmd2ArgumentParser()
6969
elderberry_parser.add_argument('arg1')
7070

7171
@cmd2.with_category('Alone')
@@ -319,7 +319,7 @@ def __init__(self, dummy):
319319
self._dummy = dummy # prevents autoload
320320
self._cut_called = False
321321

322-
cut_parser = cmd2.Cmd2ArgumentParser('cut')
322+
cut_parser = cmd2.Cmd2ArgumentParser()
323323
cut_subparsers = cut_parser.add_subparsers(title='item', help='item to cut')
324324

325325
def namespace_provider(self) -> argparse.Namespace:
@@ -340,8 +340,7 @@ def do_cut(self, ns: argparse.Namespace):
340340
self._cmd.pwarning('This command does nothing without sub-parsers registered')
341341
self._cmd.do_help('cut')
342342

343-
344-
stir_parser = cmd2.Cmd2ArgumentParser('stir')
343+
stir_parser = cmd2.Cmd2ArgumentParser()
345344
stir_subparsers = stir_parser.add_subparsers(title='item', help='what to stir')
346345

347346
@cmd2.with_argparser(stir_parser, ns_provider=namespace_provider)
@@ -613,7 +612,7 @@ class AppWithSubCommands(cmd2.Cmd):
613612
def __init__(self, *args, **kwargs):
614613
super(AppWithSubCommands, self).__init__(*args, **kwargs)
615614

616-
cut_parser = cmd2.Cmd2ArgumentParser('cut')
615+
cut_parser = cmd2.Cmd2ArgumentParser()
617616
cut_subparsers = cut_parser.add_subparsers(title='item', help='item to cut')
618617

619618
@cmd2.with_argparser(cut_parser)
@@ -874,7 +873,7 @@ class BadSubcommandApp(cmd2.Cmd):
874873
def __init__(self, *args, **kwargs):
875874
super(BadSubcommandApp, self).__init__(*args, **kwargs)
876875

877-
cut_parser = cmd2.Cmd2ArgumentParser('cut')
876+
cut_parser = cmd2.Cmd2ArgumentParser()
878877
cut_subparsers = cut_parser.add_subparsers(title='item', help='item to cut')
879878

880879
@cmd2.with_argparser(cut_parser)

0 commit comments

Comments
 (0)