-
-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for delegating CLI arguments with "--" and a special CLI_ARGS variable #327
Comments
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 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 ( |
I am also in strong support of this feature. In my case, I would be appending like so: version: '3'
passthroughArgs: true
tasks:
yarn:
... |
This comment was marked as off-topic.
This comment was marked as off-topic.
@stephencheng upcmd looks very nice and solves a lot of my use cases. How long have you worked on it? |
This comment was marked as off-topic.
This comment was marked as off-topic.
🆙 Do you have any news about this killer feature? |
My point of view: We have this: We want this: The question is: how to detect args vs task? |
@andreynering do you think if we have For example:
|
Hi @JulienBreux, I proposed a solution in this comment that I think it'll work well. |
This was implemented in e6c4706 and will be available in the next release |
Hello, I tried using this feature, but I get an error. I tried the proposed YAML config from the configuration, but it's notworking. Usage:
[...]
tasks:
yarn:
cmds:
- yarn {{.CLI_ARGS}}
[...] To check the behaviour I added a test case to the
Is this expected? Thanks |
Hi @endorama, Can you confirm you're using the latest release? I have the impression that you may be using an older release. Also, a test case like you wrote wouldn't work because the variable (for technical reasons) is added on the main package, here: e6c4706#diff-73fe859c349d50c0779c1c52c76d9c0c736905a058675d37294a447b60e0e693R172 |
@andreynering Sorry for the long wait, but I can confirm this is not happening anymore on |
Using a source-build on FreeBSD (13.0) of tags/v3.4.3, -- args aren't being set on CLI_ARGS. In addition to the below, I also tried quoting it as '{{.CLI_ARGS}}', but to no avail. I'm not well-versed in Go at all, but not a beginner coder either. I'm willing to give it a shot later this week to try figuring this out. Any potential pointers anyone could give me to get started would be much appreciated, thanks! :) Taskfile.ymlversion: '3'
tasks:
petri0: echo {{.CLI_ARGS}}
petri1:
desc: Petri Dish 1
cmds:
- echo {{.CLI_ARGS}} Execution$ task petri0
task: echo
$ task petri1
❯ task petri1
task: echo
$ task petri0 -- a b c
task: Available tasks for this project:
* petri1: Petri Dish 1
task: Task "a" not found
$ task petri1 -- a b c
task: Available tasks for this project:
* petri1: Petri Dish 1
task: Task "a" not found |
Tested again. It's a cross-platform issue between Linux & FreeBSD. Whether it's due to a compile option on my part or an API/library inconsistency between the two platforms , I'm not sure yet. |
Ignore, works with latest. |
Is it possible to pass several named or at least indexed CLI arguments? |
@dulataldazharov You can pass multiple arguments after task default -- arg1 arg2 'arg number 3' cmd: echo {{.CLI_ARGS}} echo arg1 arg2 'arg number 3' If you need to treat them separately, you need different variables. |
@andreynering it doesn't seem to be working with v3@latest (go install):
Should I file a separate issue for it? |
Nevermind, it was on my end - the tasks were invoked with |
Hi. Is it possible to isolate a specific argument from .CLI_ARGS? I've been trying this, but I got numbers, I guess the index, but not the value. # Task
demo:
cmds:
- echo "{{index .CLI_ARGS 0}}"`
# Command
task demo -- arg0 arg1 arg2
# Output
task: [demo] echo "105"
105` Thanks |
@stevensgarcia I suggest you to ask for different variable names instead of trying to use |
Hi seems go-task is somehow sprig complaint (similar to helm) and this hack seem to be working: cmds:
- echo {{(split " " .CLI_ARGS)._0}}
- echo {{(split " " .CLI_ARGS)._1}} |
@vaclav-dvorak Yes, we use slim-sprig, a stripped down version of Keep in mind that
We might want to add a function |
This is 100% true... ive posted it as a hack that was usefull for my usecase where i want to pass multiple single word arguments to script :) having a dedicated "safe" template function for it would be perfect. |
Issue created: #1040 |
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:
Is it possible to have the ability for a command like
task aws -- ls s3://my-bucket
to be translated todocker-compose run --rm aws ls s3://my-bucket
, meaningtask
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 writetask 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.
The text was updated successfully, but these errors were encountered: