comparison example/example.py @ 327:e9eea93c777c

initial args working
author catherine@dellzilla
date Thu, 11 Feb 2010 18:22:17 -0500
parents 237a89d5a4a9
children 99dd71cb477a
comparison
equal deleted inserted replaced
326:237a89d5a4a9 327:e9eea93c777c
1 '''A sample application for cmd2.''' 1 '''A sample application for cmd2.'''
2 2
3 from cmd2 import Cmd, make_option, options, Cmd2TestCase, run 3 from cmd2 import Cmd, make_option, options, run
4 import unittest, optparse, sys 4 import unittest, optparse, sys
5 5
6 class CmdLineApp(Cmd): 6 class CmdLineApp(Cmd):
7 multilineCommands = ['orate'] 7 multilineCommands = ['orate']
8 Cmd.shortcuts.update({'&': 'speak'}) 8 Cmd.shortcuts.update({'&': 'speak'})
30 do_say = do_speak # now "say" is a synonym for "speak" 30 do_say = do_speak # now "say" is a synonym for "speak"
31 do_orate = do_speak # another synonym, but this one takes multi-line input 31 do_orate = do_speak # another synonym, but this one takes multi-line input
32 32
33 c = CmdLineApp() 33 c = CmdLineApp()
34 run(c) 34 run(c)
35
36 '''
37 class TestMyAppCase(Cmd2TestCase):
38 CmdApp = CmdLineApp
39 parser = optparse.OptionParser()
40 parser.add_option('-t', '--test', dest='test', action="store_true",
41 help='Test against transcript(s) in FILE (wildcards OK)')
42 (callopts, callargs) = parser.parse_args()
43 if callopts.test:
44 CmdLineApp.testfiles = callargs
45 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
46 unittest.main()
47 else:
48 CmdLineApp().cmdloop()'''