Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go-task (taskfile) pass variables from command line

Tags:

taskfile

I create a few jobs using Go-Task but I don't find any reference in the API docs of how to pass variables as command line arguments.

Currently I use .CLI_ARGS to pass a sequence of numbers which I use in my jobs, but I want to pass from the command line also something like: CERT_PATH and CERT_KEY.

I thought something like:

task MyTaskName vars=CERT_PATH:value;CERT_KEY:value -- ARG1 ARG2 ARG3

Is this possible?

like image 435
DAG Avatar asked Oct 21 '25 03:10

DAG


1 Answers

Just use a syntax similar to shell/make to pass variable after task name:

task MyTaskName CERT_PATH=value CERT_KEY=value -- ARG1 ARG2 ARG3

From https://taskfile.dev/usage/#variables:

Since some shells do not support the above syntax to set environment variables (Windows) tasks also accept a similar style when not at the beginning of the command.

$ task write-file FILE=file.txt "CONTENT=Hello, World!" print "MESSAGE=All done!"

like image 167
ei-grad Avatar answered Oct 23 '25 20:10

ei-grad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!