示例#1
0
文件: main.py 项目: geertj/python-cli
def main():
    """Test driver for python-cli."""
    parser = create(OptionParser)
    parser.add_option('-f',
                      '--filter',
                      metavar='FILE',
                      help='execute commands from FILE')
    parser.add_option('-d',
                      '--debug',
                      action='store_true',
                      default=False,
                      help='enable debugging mode')
    parser.add_option(
        '-v',
        '--verbose',
        action='store_const',
        dest='verbosity',
        default=0,
        const=10,
        help='be verbose',
    )
    opts, args = parser.parse_args()

    if opts.filter:
        try:
            cmdin = file(opts.filter)
        except IOError, e:
            sys.stderr.write('error: %s\n' % e.strerror)
            sys.exit(1)
示例#2
0
def main():
    """Test driver for python-cli."""
    parser = create(OptionParser)
    parser.add_option('-f', '--filter', metavar='FILE',
                      help='execute commands from FILE')
    parser.add_option('-d', '--debug', action='store_true',
                      default=False, help='enable debugging mode')
    parser.add_option('-v', '--verbose', action='store_const',
                      dest='verbosity', default=0, const=10,
                      help='be verbose',)
    opts, args = parser.parse_args()

    if opts.filter:
        try:
            cmdin = file(opts.filter)
        except IOError, e:
            sys.stderr.write('error: %s\n' % e.strerror)
            sys.exit(1)
示例#3
0
    parser = create(OptionParser)
    parser.add_option('-f', '--filter', metavar='FILE',
                      help='execute commands from FILE')
    parser.add_option('-d', '--debug', action='store_true',
                      default=False, help='enable debugging mode')
    parser.add_option('-v', '--verbose', action='store_const',
                      dest='verbosity', default=0, const=10,
                      help='be verbose',)
    opts, args = parser.parse_args()

    if opts.filter:
        try:
            cmdin = file(opts.filter)
        except IOError, e:
            sys.stderr.write('error: %s\n' % e.strerror)
            sys.exit(1)
    else:
        cmdin = sys.stdin

    context = create(TestContext, cmdin)
    context.settings['cli:debug'] = opts.debug
    context.settings['cli:verbosity'] = opts.verbosity

    if len(args) == 0:
        context.execute_loop()
    else:
        command = ' '.join(args) + '\n'
        context.execute_string(command)

    sys.exit(context.status)
示例#4
0
文件: main.py 项目: geertj/python-cli
        '-v',
        '--verbose',
        action='store_const',
        dest='verbosity',
        default=0,
        const=10,
        help='be verbose',
    )
    opts, args = parser.parse_args()

    if opts.filter:
        try:
            cmdin = file(opts.filter)
        except IOError, e:
            sys.stderr.write('error: %s\n' % e.strerror)
            sys.exit(1)
    else:
        cmdin = sys.stdin

    context = create(TestContext, cmdin)
    context.settings['cli:debug'] = opts.debug
    context.settings['cli:verbosity'] = opts.verbosity

    if len(args) == 0:
        context.execute_loop()
    else:
        command = ' '.join(args) + '\n'
        context.execute_string(command)

    sys.exit(context.status)