Skip to content

choices from command #232

@richard-kramer-work

Description

@richard-kramer-work

(comming from using usage in mise tasks)

It would be nice to define possible choices values similar to the complete specification complete "foo" run="my_command".

Currently, I have the option to manually define all possible values in choices and have them show up in the help/docs. Or have my autocomplete options generated by an external command, but not show the options in any docs.

But sometimes my possible choices are options belonging to an external tool (e.g., services in a compose config) and I don't want to manually write them into my spec.

Example:

Manually defined choices

#!/usr/bin/env bash
# .mise/tasks/build
#MISE description="Build the docker images."
#
#USAGE arg "<services>..." help="The services to build." default="app database" {
#USAGE   choices "app" "database"
#USAGE }

#
mise run build --help
# =>
# Usage: build [services]...

# Arguments:
#   [services]...
#     The services to build.
#     [possible values: app, database]
mise run build <tab><tab>
# =>
# app database

No choices, but with autocomplete

#!/usr/bin/env bash
# .mise/tasks/build
#MISE description="Build the docker images."
#
#USAGE arg "<services>..." help="The services to build."
#USAGE complete "services" run="docker compose config | yq '.services | keys[]'"

#
mise run build --help
# =>
# Usage: build [services]...

# Arguments:
#   [services]...
#     The services to build.
mise run build <tab><tab>
# =>
# app database

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions