Nargit
Nargit
TTask
Created by Nargit on 3/27/2025 in #help
Requires vars and CLI_ARGS cohabitation ?
I would like to simplify the usage of task and vars when using the cli
tasks:
default:
requires:
vars:
- MY_ARG
vars:
MY_ARG : '{{ index (splitArgs .CLI_ARGS) 0 }}'
cmds:
- echo "Hello {{ .MY_ARG }}"
tasks:
default:
requires:
vars:
- MY_ARG
vars:
MY_ARG : '{{ index (splitArgs .CLI_ARGS) 0 }}'
cmds:
- echo "Hello {{ .MY_ARG }}"
task # no args will trigger an errors
task # no args will trigger an errors
task -- foo # will work
task -- foo # will work
When calling task without args, requires is not triggerd. Without the fallback to empty string, I get an error with index out of range: 0 which make requires totaly useless. I know CLI_ARGS is not used to manage task variables and instead I should use task MY_ARG=my_value but i believe task is very close to be used as a regular CLI.
4 replies