def load_config(func):
"""Decorator for add load config file option"""
@functools.wraps(func)
def internal(*args, **kwargs):
filename = kwargs.pop('config')
if filename is None:
click.echo('--config option is required.', err=True)
raise SystemExit(1)
config = load(pathlib.Path(filename))
kwargs['config'] = config
return func(*args, **kwargs)
decorator = click.option(
'--config',
'-c',
type=click.Path(exists=True),
envvar='YUI_CONFIG_FILE_PATH',
)
return decorator(internal)
评论列表
文章目录