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)
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)
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)
'-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)