Skip to content

Support for wildcard autocomplete #2484

@tj-smith47

Description

@tj-smith47

Description

Given the following wildcard task:

tasks:
  :app:*:up:
    desc: Spin up a specific app in a devcontainer
    cmds:
      - cmd: test -d ~/src/{{index .MATCH 0}} || task clone:{{index .MATCH 0}}
      - devcontainer up --workspace-folder .

It would be nice to be able to provide a list of valid autocompletion targets for the wildcard. For example:

tasks:
  :app:*:up:
    autocompletion: task app:targets | grep '^-' | tr -d '- '
    desc: Spin up a specific app in a devcontainer
    cmds:
      - cmd: test -d ~/src/{{index .MATCH 0}} || task clone:{{index .MATCH 0}}
      - devcontainer up --workspace-folder .

So if I had ~/src/app_one, ~/src/app_two, and ~/src/third_app, and task app:*:[up|down], I would get:

$ task app:targets
APP TARGETS:
- app_one
- app_two
- third_app
$ task app:a # Tab
task app:app_one:up    -- [description]
task app:app_one:down  -- [description]
task app:app_two:up    -- [description]
task app:app_two:down  -- [description]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: completionsChanges related to shell completions and scripts.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions