1515class ArgumentAndOptionPrinter (cmd2 .Cmd ):
1616 """Example cmd2 application where we create commands that just print the arguments they are called with."""
1717
18- def __init__ (self ):
18+ def __init__ (self ) -> None :
1919 # Create command shortcuts which are typically 1 character abbreviations which can be used in place of a command
2020 shortcuts = dict (cmd2 .DEFAULT_SHORTCUTS )
2121 shortcuts .update ({'$' : 'aprint' , '%' : 'oprint' })
2222 super ().__init__ (shortcuts = shortcuts )
2323
24- def do_aprint (self , statement ):
24+ def do_aprint (self , statement ) -> None :
2525 """Print the argument string this basic command is called with."""
2626 self .poutput (f'aprint was called with argument: { statement !r} ' )
2727 self .poutput (f'statement.raw = { statement .raw !r} ' )
2828 self .poutput (f'statement.argv = { statement .argv !r} ' )
2929 self .poutput (f'statement.command = { statement .command !r} ' )
3030
3131 @cmd2 .with_argument_list
32- def do_lprint (self , arglist ):
32+ def do_lprint (self , arglist ) -> None :
3333 """Print the argument list this basic command is called with."""
3434 self .poutput (f'lprint was called with the following list of arguments: { arglist !r} ' )
3535
3636 @cmd2 .with_argument_list (preserve_quotes = True )
37- def do_rprint (self , arglist ):
37+ def do_rprint (self , arglist ) -> None :
3838 """Print the argument list this basic command is called with (with quotes preserved)."""
3939 self .poutput (f'rprint was called with the following list of arguments: { arglist !r} ' )
4040
@@ -45,7 +45,7 @@ def do_rprint(self, arglist):
4545 oprint_parser .add_argument ('words' , nargs = '+' , help = 'words to print' )
4646
4747 @cmd2 .with_argparser (oprint_parser )
48- def do_oprint (self , args ):
48+ def do_oprint (self , args ) -> None :
4949 """Print the options and argument list this options command was called with."""
5050 self .poutput (f'oprint was called with the following\n \t options: { args !r} ' )
5151
@@ -55,7 +55,7 @@ def do_oprint(self, args):
5555 pprint_parser .add_argument ('-r' , '--repeat' , type = int , help = 'output [n] times' )
5656
5757 @cmd2 .with_argparser (pprint_parser , with_unknown_args = True )
58- def do_pprint (self , args , unknown ):
58+ def do_pprint (self , args , unknown ) -> None :
5959 """Print the options and argument list this options command was called with."""
6060 self .poutput (f'oprint was called with the following\n \t options: { args !r} \n \t arguments: { unknown } ' )
6161
0 commit comments