Skip to content

Commit 8dd77d0

Browse files
committed
Fixed comments in examples/command_sets.py
1 parent 39b877a commit 8dd77d0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

examples/command_sets.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
"""This example revolves around the CommandSet feature for modularizing commands.
2+
"""Example revolving around the CommandSet feature for modularizing commands.
33
44
It attempts to cover basic usage as well as more complex usage including dynamic loading and unloading of CommandSets, using
55
CommandSets to add subcommands, as well as how to categorize command in CommandSets. Here we have kept the implementation for
@@ -32,28 +32,30 @@
3232
@with_default_category(COMMANDSET_BASIC)
3333
class AutoLoadCommandSet(CommandSet):
3434
def __init__(self) -> None:
35+
"""CommandSet class for auto-loading commands at startup."""
3536
super().__init__()
3637

3738
def do_hello(self, _: cmd2.Statement) -> None:
38-
"""Prints hello."""
39+
"""Print hello."""
3940
self._cmd.poutput('Hello')
4041

4142
def do_world(self, _: cmd2.Statement) -> None:
42-
"""Prints World."""
43+
"""Print World."""
4344
self._cmd.poutput('World')
4445

4546

4647
@with_default_category(COMMANDSET_DYNAMIC)
4748
class LoadableFruits(CommandSet):
4849
def __init__(self) -> None:
50+
"""CommandSet class for dynamically loading commands related to fruits."""
4951
super().__init__()
5052

5153
def do_apple(self, _: cmd2.Statement) -> None:
52-
"""Prints Apple."""
54+
"""Print Apple."""
5355
self._cmd.poutput('Apple')
5456

5557
def do_banana(self, _: cmd2.Statement) -> None:
56-
"""Prints Banana"""
58+
"""Print Banana."""
5759
self._cmd.poutput('Banana')
5860

5961
banana_description = "Cut a banana"
@@ -69,14 +71,15 @@ def cut_banana(self, ns: argparse.Namespace) -> None:
6971
@with_default_category(COMMANDSET_DYNAMIC)
7072
class LoadableVegetables(CommandSet):
7173
def __init__(self) -> None:
74+
"""CommandSet class for dynamically loading commands related to vegetables."""
7275
super().__init__()
7376

7477
def do_arugula(self, _: cmd2.Statement) -> None:
75-
"Prints Arguula."
78+
"Print Arguula."
7679
self._cmd.poutput('Arugula')
7780

7881
def do_bokchoy(self, _: cmd2.Statement) -> None:
79-
"""Prints Bok Choy."""
82+
"""Print Bok Choy."""
8083
self._cmd.poutput('Bok Choy')
8184

8285
bokchoy_description = "Cut some bokchoy"
@@ -85,13 +88,15 @@ def do_bokchoy(self, _: cmd2.Statement) -> None:
8588

8689
@cmd2.as_subcommand_to('cut', 'bokchoy', bokchoy_parser, help=bokchoy_description.lower())
8790
def cut_bokchoy(self, ns: argparse.Namespace) -> None:
91+
"""Cut bokchoy."""
8892
self._cmd.poutput('Bok Choy: ' + ns.style)
8993

9094

9195
class CommandSetApp(cmd2.Cmd):
9296
"""CommandSets are automatically loaded. Nothing needs to be done."""
9397

9498
def __init__(self) -> None:
99+
"""Cmd2 application for demonstrating the CommandSet features."""
95100
# This prevents all CommandSets from auto-loading, which is necessary if you don't want some to load at startup
96101
super().__init__(auto_load_commands=False)
97102

@@ -109,6 +114,7 @@ def __init__(self) -> None:
109114
@with_argparser(load_parser)
110115
@with_category(COMMANDSET_LOAD_UNLOAD)
111116
def do_load(self, ns: argparse.Namespace) -> None:
117+
"""Load a CommandSet at runtime."""
112118
if ns.cmds == 'fruits':
113119
try:
114120
self.register_command_set(self._fruits)
@@ -126,6 +132,7 @@ def do_load(self, ns: argparse.Namespace) -> None:
126132
@with_argparser(load_parser)
127133
@with_category(COMMANDSET_LOAD_UNLOAD)
128134
def do_unload(self, ns: argparse.Namespace) -> None:
135+
"""Unload a CommandSet at runtime."""
129136
if ns.cmds == 'fruits':
130137
self.unregister_command_set(self._fruits)
131138
self.poutput('Fruits unloaded')

0 commit comments

Comments
 (0)