cli_module.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:cligenerator 作者: bharadwaj-raju 项目源码 文件源码
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('.', '_'))()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号