def run_program(args: argparse.Namespace, parser: argparse.ArgumentParser) -> None: if args.version: print('online-judge-tools {} (+ online-judge-api-client {})'.format( version.__version__, api_version.__version__)) sys.exit(0) if args.verbose: log.setLevel(log.logging.DEBUG) log.debug('args: %s', str(args)) if args.subcommand in ['download', 'd', 'dl']: download(args) elif args.subcommand in ['login', 'l']: login(args) elif args.subcommand in ['submit', 's']: submit(args) elif args.subcommand in ['test', 't']: test(args) elif args.subcommand in ['test-reactive', 't/r']: test_reactive(args) elif args.subcommand in ['generate-output', 'g/o']: generate_output(args) elif args.subcommand in ['generate-input', 'g/i']: generate_input(args) else: parser.print_help(file=sys.stderr) sys.exit(1)
def run_program(args: argparse.Namespace, parser: argparse.ArgumentParser) -> None: if args.version: print('online-judge-tools {} (+ online-judge-api-client {})'.format( version.__version__, api_version.__version__)) sys.exit(0) logger.debug('args: %s', str(args)) # print the version to use for user-supporting logger.info('online-judge-tools %s (+ online-judge-api-client %s)', version.__version__, api_version.__version__) # TODO: make functions for subcommand take a named tuple instead of the raw result of argparse. Using named tuples make code well-typed. # TODO: make functions for subcommand always return. The current implementation sometimes calls sys.exit(1), but this is not so good to write tests. if args.subcommand in ['download', 'd', 'dl']: download(args) elif args.subcommand in ['login', 'l']: login(args) elif args.subcommand in ['submit', 's']: submit(args) elif args.subcommand in ['test', 't']: test(args) elif args.subcommand in ['test-reactive', 't/r']: test_reactive(args) elif args.subcommand in ['generate-output', 'g/o']: generate_output(args) elif args.subcommand in ['generate-input', 'g/i']: generate_input(args) else: parser.print_help(file=sys.stderr) sys.exit(1)