Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamwasila
Copy link
Contributor

My attempt to solve issue described in #321 . Should work correctly though it needs review.

Simplest Taskfile.yml to demonstrate effects of this change:

version: '2'
tasks:
  default:
    deps:
      - task: test
        alias: "dep-foo"
    cmds:
      - task: test
        alias: "foo-bar"
      - task: test
  test:
    sources:
      - Taskfile.yml
    generates:
      - Taskfile.yml

Output before:

task: Task "test" is up to date
task: Task "test" is up to date
task: Task "test" is up to date

Expected output with change:

task: Task "dep-foo" is up to date
task: Task "foo-bar" is up to date
task: Task "test" is up to date

Also there were some concerns if name "alias" is a good one for such property. Of the top of my head I have two other options: "name-override" or "label". Are these any better?

@adamwasila
Copy link
Contributor Author

I think I found sth that may be much more elegant solution to the problem I have. Here, I use alias (or label) on task itself and I can use variables to simply substitute it with any name I want when it is executed using deps or direct call. Example Taskfile with the syntax:

version: '3'
tasks:
  default:
    deps:
      - task: test
        vars: 
          ALIAS: IAMDEPTASK
    cmds:
      - task: test
        vars: 
          ALIAS: IAMSUBTASK
      - task: test
  test:
    alias: "{{.ALIAS}}"
    sources:
      - Taskfile.yml
    generates:
      - Taskfile.yml

As you may see, implementation is minimal and modifies just task struct but nothing else. Another advantage is it can be used to customize task name in every context, even if task is called directly.

Problems I found so far: in example above, last task currently generates message task: Task "<no value>" is up to date while it should use original name of the task in such case. But that seems trivial to fix.

I leaved all changes in this branch so far waiting for any comments, but if accepted only last commit will be one proposed to merge (updated with tests, documentation etc. if required).

@andreynering
Copy link
Member

Hi @adamwasila,

I liked this approach, it seems really simple.

I like label much more than alias, though, specially because there's another feature request that would be called "alias" (#268) and this name makes more sense there than here.

Label is an alternative name for task that replace it when printed in following context eg.:

- log: when given task is up to date and is skipped from execution
- log: when given task is NOT up to date (`--status` command)
- in `--summary` and `--list` commands output
@adamwasila adamwasila force-pushed the subtask-alias branch 2 times, most recently from 5b1bd73 to 08e10b2 Compare June 14, 2020 12:34
@adamwasila
Copy link
Contributor Author

Thanks for your comments. I have implemented it accordingly and it is ready for review now.

@adamwasila adamwasila marked this pull request as ready for review June 14, 2020 13:21
@andreynering andreynering linked an issue Jun 14, 2020 that may be closed by this pull request
@andreynering
Copy link
Member

Hi @adamwasila,

Seems great, thanks! ❤️

@andreynering andreynering merged commit c6d9201 into go-task:v3 Jun 14, 2020
andreynering added a commit that referenced this pull request Jun 14, 2020
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.

Allow overriding the task name in the logger output

2 participants