Skip to content

Improve autocomplete for flag arguments #224

@tiagoposse

Description

@tiagoposse

Could autocompletions be made so that when trying to autocomplete a flag, only allowed values for it are shown?

As an example, given the following command:

commands:
- name: deploy

  args:
  - name: name
    required: true
    help: Name of the service
    repeatable: true
    allowed: [ a, b, c ]
  flags:
  - long: --stage
    short: -s
    help: Stage to manage
    arg: stage
    allowed:
      - dev
      - test
      - prod

Autocompletions will be as follows:

./cli deploy <TAB>
--help          a            test
--stage        b           prod
-h                 c
-s                 dev

Triggering autocomplete for the -s flag will result in the same autocompletions being shown:

./cli deploy -s <TAB>
--help          a            test
--stage        b           prod
-h                 c
-s                 dev

Would be clearer if:

  • when autocompleting a command, show possible flags and allowed values for the positional argument
  • when autocompleting a flag, show possible values for the flag only

Example:
For the command:

./cli deploy <TAB>
--help          a
--stage        b
-h                 c
-s

For the flag

./cli deploy -s <TAB>
dev
test
prod

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions