task icon indicating copy to clipboard operation
task copied to clipboard

{{.TASK}} remains in task listing

Open MarioSchwalbe opened this issue 3 years ago • 1 comments

Versions

  • Task version: v3.14.0
  • Operating System: Mac OS X 10.15.7

Example Taskfile showing the issue

version: '3'

tasks:
  DoesNotWork:
    desc:  DoesNotWork
    label: '{{.TASK}}'
    cmds:
      - echo "PARAM = '{{ .PARAM | trim }}'"

  DoesWork:
    desc:  DoesWork
    label: '{{.TASK}}'
    cmds:
      - echo "PARAM = '{{ .PARAM | default "" | trim }}'"

Run:

$ task -l
task: Available tasks for this project:
* {{.TASK}}: 	DoesNotWork
* DoesWork: 	DoesWork

Notes:

  • Both tasks are intended to be called from the command-line but also embedded within other tasks by passing their task name as variable TASK.
  • The task DoesNotWork fails if run without the parameter (which is expected):
    $ task DoesNotWork
    template: :1:27: executing "" at <trim>: invalid value; expected string
    
    The task DoesWork would work due to the provided default.

However, this should not affect the output of task -l. Or is this a hidden feature to validate the correctness of tasks? Like: If it looks like {{.TASK}}, some default is missing.

MarioSchwalbe avatar Aug 01 '22 14:08 MarioSchwalbe

Hi @MarioSchwalbe, thanks for reporting this bug.

IIRC templating is skipped completely for --list.

We already have a more lightweight variation of the function that does templating (which is faster because it skips shell commands from running). We could consider doing that for this use case as well.

andreynering avatar Aug 04 '22 01:08 andreynering

It seems that this is not a problem anymore on the current release.

I'm closing this. If anyone continue to experience this issue, let me know.

andreynering avatar Aug 10 '23 02:08 andreynering