def init(ctx):
"""
Initializes a linchpin project, which generates an example PinFile, and
creates the necessary directory structure for topologies and layouts.
ctx: Context object defined by the click.make_pass_decorator method
"""
pf_w_path = _get_pinfile_path(exists=False)
try:
# lpcli.lp_init(pf_w_path, targets) # TODO implement targets option
lpcli.lp_init(pf_w_path)
except LinchpinError as e:
ctx.log_state(e)
sys.exit(1)
python类make_pass_decorator()的实例源码
def browserstacker_command(func):
"""
Shortcut to define command for BrowserStacker.
"""
pass_decorator = click.make_pass_decorator(APIWrapper)
return cli.command()(pass_decorator(func))
def context():
"""
Configuration context holder
"""
return click.make_pass_decorator(Context, ensure=True)
def __init__(self):
self.options = []
self.pass_state = click.make_pass_decorator(State, ensure=True)