Skip to content

Unable to use Requires to limit Wildcards #1955

@ionfury

Description

@ionfury

From the docs I expect to be able to use requires and wildcard arguments together to limit the possible wildcards. Below is an example, following from the initial wildcard PR #1489:

---
version: "3"

tasks:
  start-*:
    desc: "Starts a service.  Options: web, db"
    vars:
      SERVICE: "{{ index .MATCH 0 }}"
    cmds:
      - echo "Starting {{.SERVICE}}"
    requires:
      vars:
        - name: SERVICE
          enum: ["web", "db"]

And the output:

❯ task start-a
task: Task "start-*" cancelled because it is missing required variables: SERVICE
❯ task start-web
task: Task "start-*" cancelled because it is missing required variables: SERVICE

Removing the requires block results in the following (correct) output:

❯ task start-web
task: [start-*] echo "Starting web"
Starting web

I would expect requires to validate that SERVICE is in ["web", "db"]. If this assumption or my implementation is incorrect, please forgive me.

  • Task version:
Task version: 3.40.1 ()
  • Operating system:
ProductName:            macOS
ProductVersion:         14.4.1
BuildVersion:           23E224
  • Experiments enabled: none

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions