test.py
author Alexander Solovyov <piranha@piranha.org.ua>
Mon, 13 Jul 2009 18:42:46 +0300
changeset 35 dc7f13ea0f09
parent 32 9d42e3d16bcf
child 60 1d27eceed4d2
permissions -rwxr-xr-x
link to song text, just for fun

#!/usr/bin/env python

import sys

from finaloption import dispatch, command


@command(usage='[-t]', shortlist=True)
def simple(test=('t', False, 'just test execution')):
    '''Just simple command to do nothing.

    I assure you! Nothing to look here. ;-)
    '''
    print locals()

cplx_opts = [('p', 'pass', False, 'don\'t run the command'),
             ('', 'exit', 0, 'exit with supplied code (default: 0)')]

@command(cplx_opts, usage='[-p] [--exit value] ...', name='complex')
def complex_(*args, **opts):
    '''That's more complex command indented to do something

    Let's try to do that (what?!)
    '''
    if opts.get('pass'):
        return
    # test ui
    if opts.get('exit'):
        sys.exit(opts['exit'])

if __name__ == '__main__':
    dispatch()