You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manually parse the arbritray args yourself, using a -- seperator.
Add an option to the task.
@taskdefexample1(c):
rest_args=sys.argv[sys.argv.index("--") +1 :] if"--"insys.argvelse []
print("rest_args = {}".format(rest_args))
# use shlex.join() if you're on Python 3.8c.run(
"docker run -it myapp {}".format(" ".join([shlex.quote(x) forxinrest_args]))
)
@taskdefexample2(c, docker_args=""):
print("docker_args = {!r}".format(docker_args))
c.run("docker run -it myapp {}".format(docker_args))
$ inv --dry --echo example1 -- a b "c with spaces"
rest_args = ['a', 'b', 'c with spaces']
docker run -it myapp a b 'c with spaces'
$ inv --dry --echo example2 --docker-args 'a b "c with spaces"'
docker_args = 'a b "c with spaces"'
docker run -it myapp a b "c with spaces"
I want to write a task such as
invoke run bash -c echo "hello"
where the taskrun
is defined as follows in bash:How do I do the equivalent of "$@" in pyinvoke?
The text was updated successfully, but these errors were encountered: