我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用flask_script.add_help()。
def create_parser(self, *args, **kwargs): func_stack = kwargs.pop('func_stack',()) parent = kwargs.pop('parent',None) parser = argparse.ArgumentParser(*args, add_help=False, **kwargs) help_args = self.help_args while help_args is None and parent is not None: help_args = parent.help_args parent = getattr(parent,'parent',None) if help_args: from flask_script import add_help add_help(parser,help_args) for option in self.get_options(): if isinstance(option, Group): if option.exclusive: group = parser.add_mutually_exclusive_group( required=option.required, ) else: group = parser.add_argument_group( title=option.title, description=option.description, ) for opt in option.get_options(): group.add_argument(*opt.args, **opt.kwargs) else: parser.add_argument(*option.args, **option.kwargs) parser.set_defaults(func_stack=func_stack+(self,)) self.parser = parser self.parent = parent return parser