choices from command

Open
#232 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
cli

Research direction

Start with the existing choices and complete specifications described in the issue and compare their help output and tab-completion behavior. Define how command-generated choices should connect these two behaviors; done means the example values appear in both possible-values help and completion output.

Written by the indexing model from the issue text.

Description

(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
Dominant language
Rust
Stars
1k
Forks
59
Avg merge
5h 58m
Merged PRs (30d)
362

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jdx/usage

All issues in jdx/usage

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.