1
1
#!/usr/bin/env python3
2
- """A simple example cmd2 application demonstrating the following:
2
+ """A simple example cmd2 application demonstrating many common features.
3
+
4
+ Features demonstrated include all of the following:
3
5
1) Colorizing/stylizing output
4
6
2) Using multiline commands
5
7
3) Persistent history
25
27
26
28
27
29
class BasicApp (cmd2 .Cmd ):
30
+ """Cmd2 application to demonstrate many common features."""
31
+
28
32
CUSTOM_CATEGORY = 'My Custom Commands'
29
33
30
34
def __init__ (self ) -> None :
35
+ """Initialize the cmd2 application."""
31
36
# Startup script that defines a couple aliases for running shell commands
32
37
alias_script = pathlib .Path (__file__ ).absolute ().parent / '.cmd2rc'
33
38
@@ -39,7 +44,7 @@ def __init__(self) -> None:
39
44
multiline_commands = ['echo' ],
40
45
persistent_history_file = 'cmd2_history.dat' ,
41
46
shortcuts = shortcuts ,
42
- startup_script = alias_script ,
47
+ startup_script = str ( alias_script ) ,
43
48
)
44
49
45
50
# Prints an intro banner once upon application startup
@@ -82,7 +87,7 @@ def do_intro(self, _: cmd2.Statement) -> None:
82
87
83
88
@cmd2 .with_category (CUSTOM_CATEGORY )
84
89
def do_echo (self , arg : cmd2 .Statement ) -> None :
85
- """Example of a multiline command."""
90
+ """Multiline command."""
86
91
self .poutput (
87
92
stylize (
88
93
arg ,
0 commit comments