Does go-task currently offer the option of "passthrough" arguments? For example, if I have currently have a task to run the AWS CLI out of a Docker container:
tasks:
aws:
cmds:
- docker-compose run --rm aws
Is it possible to have the ability for a command like task aws -- ls s3://my-bucket to be translated to docker-compose run --rm aws ls s3://my-bucket, meaning task will pass through anything after -- to the underlying shell command?
This is a more convenient way to pass extra variables compared to the current approach: task write-file FILE=file.txt "CONTENT=Hello, World!". Currently, using this approach allows me to write task aws CMD="ls s3://my-bucket" but the extra variable definition and quotes creates a lot of friction that I think can be alleviated with my proposal.
If this is not possible, it would be a really nice capability to have in the future.
Hi @huy-nguyen, thanks for opening this issue!
This is something that already came up recently by @mbertschler at #316.
Since more people think this would be important, I'll keep this issue open so this could be considered in the future.
I think that what would work is a mixture of these both proposals. We'd both require -- in the CLI to separate these args from other tasks and flags, and also require a special var to be concatenated in the right task[s]:
task yarn -- test-ci
version: '3'
tasks:
yarn:
dir: js
cmds:
- yarn {{.CLI_ARGS}}
@andreynering Your proposal sounds great. The one inconvenience with my current workaround of declaring variables on the command line (task write-file FILE=file.txt "CONTENT=Hello, World!") is that the shell doesn't offer tab completions within quoted strings. Because of that, allowing pass through arguments after -- is the superior solution.
I am also in strong support of this feature. In my case, I would be appending {{.CLI_ARGS}} to most of my commands because I tag on extra arguments ad-hoc pretty frequently. Maybe there could be a way to make enable it as default with some option to reduce duplication?
like so:
version: '3'
passthroughArgs: true
tasks:
yarn:
...
@huy-nguyen you may want to try it out of: https://github.com/upcmd/up, you can pass through args/vars to a callable task using call func
It is flexible enough, docs here: https://upcmd.netlify.app/call-func/c0020/
@stephencheng upcmd looks very nice and solves a lot of my use cases. How long have you worked on it?
@stephencheng upcmd looks very nice and solves a lot of my use cases. How long have you worked on it?
@huy-nguyen half year on code base itself, but this is not only about the code, it's about the devpos industry experience I accumulated many years and try to resolve those pain points, all counted, probably a few years :)
馃啓 Do you have any news about this killer feature?
My point of view:
We have this: task firstTask secondTask
We want this: task firstTaks [ARGS] or task firstTaks secondTask [ARGS].
The question is: how to detect args vs task?
@andreynering do you think if we havepassthroughArgs: true we can cancel the last error and pass arguments to each tasks?
For example:
task taskExists0 taskExists1 taskNotExists0 with passthroughArgs: true = exec taskExists0 with args taskNotExists0 and exec taskExists1 with args taskNotExists0 but no errortask taskExists0 taskExists1 taskNotExists0 without passthroughArgs: true = error taskNotExists0 doesn't exists?Hi @JulienBreux,
I proposed a solution in this comment that I think it'll work well.
Most helpful comment
Hi @huy-nguyen, thanks for opening this issue!
This is something that already came up recently by @mbertschler at #316.
Since more people think this would be important, I'll keep this issue open so this could be considered in the future.
I think that what would work is a mixture of these both proposals. We'd both require
--in the CLI to separate these args from other tasks and flags, and also require a special var to be concatenated in the right task[s]: