Example #1
0
def dispatch(args=None, cmdtable=None, globaloptions=None, middleware=None,
             scriptname=None):
    global _dispatcher
    if not _dispatcher:
        _dispatcher = Dispatcher(cmdtable, globaloptions, middleware)
    else:
        if cmdtable:
            _dispatcher._cmdtable = CmdTable(cmdtable)
        if globaloptions:
            _dispatcher._globaloptions = [Option(o) for o in globaloptions]
        if middleware:
            _dispatcher.middleware = middleware
    return _dispatcher.dispatch(args, scriptname)
Example #2
0
def subcmd1(quiet=('q', False, 'quietly'),
            showhelp=('h', False, 'Print the help message')):
    '''Help for subcmd1'''
    if not quiet:
        print('running subcmd1')
    if showhelp:
        print('Showing the help:')
        subcmd1.help()

@d2.command()
def subcmd2(number):
    '''Help for subcmd2'''
    print('running subcmd2', number)

d3 = Dispatcher()
@d3.command()
def subsubcmd(loud=('l', False, 'loudly'),
              showhelp=('h', False, 'Print the help message')):
    '''Help for subsubcmd'''
    if loud:
        print('running subsubcmd')
    if showhelp:
        print('Showing the help:')
        subsubcmd.help()

d2.nest('subcmd3', d3, 'Help for subcmd3')
d.nest('cmd', d2, 'Help for cmd')

if __name__ == '__main__':
    d.dispatch()
Example #3
0
    for m in migrations:
        try:
            m.apply(env=env, fake=fake)
        except DBError as e:
            abort('cannot apply migration %s: %s' % (m, e))


@app.command()
def info(**opts):
    '''Show information about repository
    '''
    repo = opts['repo']
    print('%s:' % repo)
    print('  %s' % repo.engine)
    try:
        print('  %s applied' % len(repo.applied))
        print('  %s unapplied' % (len(repo.available) - len(repo.applied)))
    except DBError:
        print('  Uninitialized repository')


@app.command()
def version(**opts):
    '''Show nomad version
    '''
    print('Nomad v%s' % __version__)


if __name__ == '__main__':
    app.dispatch()
Example #4
0
        if not m.applied:
            try:
                m.apply(env=env)
            except DBError, e:
                abort('cannot apply migration %s: %s' % (m, e))


@app.command()
def info(**opts):
    '''Show information about repository
    '''
    repo = opts['repo']
    print '%s:' % repo
    print '  %s' % repo.engine
    try:
        print '  %s applied' % len(repo.applied)
        print '  %s unapplied' % (len(repo.available) - len(repo.applied))
    except DBError:
        print '  Uninitialized repository'


@app.command()
def version(**opts):
    '''Show nomad version
    '''
    print 'Nomad v%s' % __version__


if __name__ == '__main__':
    app.dispatch()
Example #5
0
d3 = Dispatcher()
@d3.command()
def subsubcmd(loud=('l', False, 'loudly'),
              showhelp=('h', False, 'Print the help message')):
    '''Help for subsubcmd'''
    if loud:
        print('running subsubcmd')
    if showhelp:
        print('Showing the help:')
        subsubcmd.help()

d2.nest('subcmd3', d3, 'Help for subcmd3')
d.nest('cmd', d2, 'Help for cmd')

if __name__ == '__main__':
    d.dispatch()

########NEW FILE########
__FILENAME__ = test_extopts
# First line of opttypes.py
from __future__ import print_function

import sys
from decimal import Decimal
from fractions import Fraction

from opster import command


@command()
def main(money=('m', Decimal('100.00'), 'amount of money'),