-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
feat: add ALIAS special var #1764
Conversation
Hey @DanStory, The implementation is pretty simple, so I believe we could just merge it. That said, I'm curious on what is your use case for needing this variable. Do you mind explaining? |
95e5091
to
9caa8ff
Compare
@andreynering, I am cleaning up and restructuring our monorepo's taskfiles while trying to prevent from breaking developers' current workflow via aliases that warn of the deprecation and executing the new task. We also have a lot of duplication of tasks for each application in the monorepo, so I am experimenting with ways to dedupe common tasks while keeping decent discoverability (task --list). version: '3'
tasks:
## original tasks
# old:dull:app1:
# cmd: "..."
# old:dull:app2:
# cmd: "..."
# old:dull:app3:
# cmd: "..."
## refactor all the old:dull:x tasks for this single one
## gives feedback that is deprecated for new task format
old:dull:
desc: "DEPRECATED: use new:shiny -- <app>"
vars:
APP: '{{ternary "" (splitList ":" .ALIAS | last) (eq .ALIAS .TASK)}}'
aliases:
- old:dull:app1
- old:dull:app2
- old:dull:app3
cmds:
- 'echo "DEPRECATED: use new:shiny -- {{.APP}} OR new:shiny:{{.APP}}"'
- task: 'new:shiny'
silent: true
vars:
CLI_ARGS: '{{.APP}}'
## have not decided between using ALIAS vs CLI_ARGS for new structure
new:shiny:
desc: "the new shiny"
vars:
APP: '{{ternary .CLI_ARGS (splitList ":" .ALIAS | last) (eq .ALIAS .TASK)}}'
aliases:
- new:shiny:app1
- new:shiny:app2
- new:shiny:app3
cmds:
- echo "start {{.APP}}" > go run ./cmd/task old:dull:app1
task: [old:dull] echo "DEPRECATED: use new:shiny -- app1 OR new:shiny:app1"
DEPRECATED: use new:shiny -- app1 OR new:shiny:app1
start app1
> go run ./cmd/task --dir ./testdata new:shiny -- app1
task: [new:shiny] echo "start app1"
start app1
> go run ./cmd/task --dir ./testdata new:shiny:app1
task: [new:shiny] echo "start app1"
start app1 > go run ./cmd/task --list
task: Available tasks for this project:
* new:shiny: the new shiny (aliases: new:shiny:app1, new:shiny:app2, new:shiny:app3)
* old:dull: DEPRECATED: use new:shiny -- <app> (aliases: old:dull:app1, old:dull:app2, old:dull:app3) |
@DanStory Thanks for your contribution! |
Adds
ALIAS
to special vars that represents the alias that was used when invoking the task, otherwise will be the task name.