Skip to content

Conversation

sashokbg
Copy link

This PR adds a new --var flag that allows to override variables set in the Taskfile

@andreynering
Copy link
Member

Hi @sashokbg,

Thanks for your PR, but this is probably not the right direction as we already have a proper syntax for setting vars via the CLI:

task my-task FOO=bar

So in theory there's no need for:

task my-task --var FOO=bar

There's the priority thing, but add even one more way of setting vars would just make things even for confusing.

@sashokbg
Copy link
Author

Hello @andreynering I understand, I missed out that positional args are treated as vars.

Can we please keep the variable overriding at least ?

So that I can still run task my-task FOO=bar but the FOO from cli args will take precedence over the one defined in the template file (like is the case with many other cli tools).

Thank you for your understanding

@andreynering
Copy link
Member

@sashokbg The current behavior is by design. You should use default if you want to make a variable overridable:

https://taskfile.dev/docs/reference/templating#default-values-and-coalescing

@sashokbg
Copy link
Author

ok, it is all clear now @andreynering, thank you for your explanations.

I worked on the overriding / defaults in relation to #2379 can you come check it please ?

The idea is to have variables set by interactive input, but we need to handle the case on non-TTY shells and thus use defaults etc. Any comment and proposals would be really helpful.

Thank you and have a nice day !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants