from fancycmd import command short name long name default value help s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from fancycmd import command
# short name, long name, default value, help string
opts = [('t', 'test', False, 'just test execution')]
@command(opts=opts, usage='%name [-t]')
def main(*args, **kwargs):
'''documentation'''
pass
@command(usage='%name [-t]')
def main(dirname,
test=('t', False, 'just test execution')):
'''documentation'''
pass
if __name__ == '__main__':
main()
main('-t nax'.split())
# multiple commands
from fancycmd import dispatch, command
@command(usage='%name [-t]', opts=simple_opts)
def simple(*args, **opts):
'''docs'''
pass
@command(usage='%name ...', opts=complex_opts, name='complex')
def complex_(*args, **opts):
'''docs'''
pass
if __name__ == '__main__':
dispatch(globalopts=globalopts)
dispatch(globalopts=globalopts, args='complex -p'.split())