15
15
class ArgumentAndOptionPrinter (cmd2 .Cmd ):
16
16
"""Example cmd2 application where we create commands that just print the arguments they are called with."""
17
17
18
- def __init__ (self ):
18
+ def __init__ (self ) -> None :
19
19
# Create command shortcuts which are typically 1 character abbreviations which can be used in place of a command
20
20
shortcuts = dict (cmd2 .DEFAULT_SHORTCUTS )
21
21
shortcuts .update ({'$' : 'aprint' , '%' : 'oprint' })
22
22
super ().__init__ (shortcuts = shortcuts )
23
23
24
- def do_aprint (self , statement ):
24
+ def do_aprint (self , statement ) -> None :
25
25
"""Print the argument string this basic command is called with."""
26
26
self .poutput (f'aprint was called with argument: { statement !r} ' )
27
27
self .poutput (f'statement.raw = { statement .raw !r} ' )
28
28
self .poutput (f'statement.argv = { statement .argv !r} ' )
29
29
self .poutput (f'statement.command = { statement .command !r} ' )
30
30
31
31
@cmd2 .with_argument_list
32
- def do_lprint (self , arglist ):
32
+ def do_lprint (self , arglist ) -> None :
33
33
"""Print the argument list this basic command is called with."""
34
34
self .poutput (f'lprint was called with the following list of arguments: { arglist !r} ' )
35
35
36
36
@cmd2 .with_argument_list (preserve_quotes = True )
37
- def do_rprint (self , arglist ):
37
+ def do_rprint (self , arglist ) -> None :
38
38
"""Print the argument list this basic command is called with (with quotes preserved)."""
39
39
self .poutput (f'rprint was called with the following list of arguments: { arglist !r} ' )
40
40
@@ -45,7 +45,7 @@ def do_rprint(self, arglist):
45
45
oprint_parser .add_argument ('words' , nargs = '+' , help = 'words to print' )
46
46
47
47
@cmd2 .with_argparser (oprint_parser )
48
- def do_oprint (self , args ):
48
+ def do_oprint (self , args ) -> None :
49
49
"""Print the options and argument list this options command was called with."""
50
50
self .poutput (f'oprint was called with the following\n \t options: { args !r} ' )
51
51
@@ -55,7 +55,7 @@ def do_oprint(self, args):
55
55
pprint_parser .add_argument ('-r' , '--repeat' , type = int , help = 'output [n] times' )
56
56
57
57
@cmd2 .with_argparser (pprint_parser , with_unknown_args = True )
58
- def do_pprint (self , args , unknown ):
58
+ def do_pprint (self , args , unknown ) -> None :
59
59
"""Print the options and argument list this options command was called with."""
60
60
self .poutput (f'oprint was called with the following\n \t options: { args !r} \n \t arguments: { unknown } ' )
61
61
0 commit comments