Skip to content

cli: complete goals and --on node names in fish - #426

Open
moeleak wants to merge 1 commit into
nix-community:mainfrom
moeleak:fish-completions
Open

moeleak wants to merge 1 commit into
nix-community:mainfrom
moeleak:fish-completions

Conversation

@moeleak

@moeleak moeleak commented Nov 17, 2026

Copy link
Copy Markdown

In fish, colmena apply <TAB> and colmena apply --on <TAB> both complete file names:

  • clap_complete's fish generator does not complete positional arguments ("The fish generator currently only supports named options"), so the goals of apply and apply-local are missing, although Goal is a ValueEnum.
  • --on has no value hint, and a static completion file cannot know the nodes of a hive.

gen-completions fish now appends to clap's output:

  • the possible values of the positional arguments of every visible subcommand, with their help, from the clap definitions, so new goals are picked up automatically;
  • a __fish_colmena_nodes function that evaluates the node names with colmena eval -E '{ nodes, ... }: builtins.attrNames nodes', passing on -f/--config from the command line, and completes --on with it for apply, build, exec and upload-keys, comma-separated lists included (__fish_append).

Tags are not completed: their deployment.tags needs each node's configuration to be evaluated, which took 5 s for 4 nodes here, against under 1 s for the names.

--on also gets ValueHint::Other, so bash and zsh stop offering file names for it too; elvish and PowerShell completions are unchanged.

Testing

  • nix develop -c cargo test (with a new unit test for the generated fish completions), nix fmt and nix build pass.
  • With a flake hive of 4 nodes, in fish 4.9.3 and 3.7.1:
    • colmena apply <TAB> → boot build dry-activate push switch test upload-keys
    • colmena apply --on <TAB> → the 4 node names (about 0.7 s)
    • colmena apply --on node-a,<TAB> → node-a,node-b …
    • colmena -f /path/to/flake.nix apply --on <TAB> from another directory → the node names
    • outside a hive, --on <TAB> completes nothing rather than files.

clap_complete's fish generator does not complete positional arguments,
so `colmena apply <TAB>` offered files instead of the goals, and it
cannot know the nodes of a hive, so `--on <TAB>` offered files too.

gen-completions fish now appends:

- the possible values of positional arguments, taken from the clap
  definitions (the goals of `apply` and `apply-local`);
- a completion for `--on` that evaluates the node names of the hive
  with `colmena eval`, honouring -f/--config, and completes
  comma-separated lists.

`--on` also gets `ValueHint::Other`, so bash and zsh stop offering
file names for it as well.
@moeleak
moeleak requested a review from stepbrobd as a code owner November 17, 2026 11:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant