def __init__(self):
parser = argparse.ArgumentParser(
description='A CLI tool for mymodule',
formatter_class=argparse.RawTextHelpFormatter,
usage='%(prog)s command options',
allow_abbrev=False)
parser.add_argument('command', help='Command to run.')
args = parser.parse_args(sys.argv[1:2]) # Ignore options
self._one_func_mode = False
if not hasattr(self, args.command.replace('.', '_')):
print('Unrecognized command!')
sys.exit(1)
getattr(self, args.command.replace('.', '_'))()
评论列表
文章目录