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
{{ message }}
Repository navigation
pass in arbitrary options/arguments as raw text? #693
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"
Activity
dlh commentedon Feb 18, 2020
I think you have 2 options:
--seperator.The parser appears to support accessing the remainder args, however I'm unsure how to access that property.