将参数传递给结构任务 [英] Pass parameter to fabric task

查看:63
本文介绍了将参数传递给结构任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从命令行调用"fab"时,如何将参数传递给Fabric任务?例如:

How can I pass a parameter to a fabric task when calling "fab" from the command line? For example:

def task(something=''):
    print "You said %s" % something

$ fab task "hello"
You said hello

Done.

是否可以在不按fabric.operations.prompt提示的情况下执行此操作?

Is it possible to do this without prompting with fabric.operations.prompt?

推荐答案

Fabric 2任务参数文档:

Fabric 2 task arguments documentation:

http://docs. pyinvoke.org/en/latest/concepts/invoking-tasks.html#task-command-line-arguments

Fabric 1.X使用以下语法将参数传递给任务:

Fabric 1.X uses the following syntax for passing arguments to tasks:

 fab task:'hello world'
 fab task:something='hello'
 fab task:foo=99,bar=True
 fab task:foo,bar

您可以在结构文档.

这篇关于将参数传递给结构任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆