feat(3216): swarmctl shell completions
Mirrors hivectl exactly: a `completions <shell>` verb that walks the live clap tree, and a package that pipes it into installShellCompletion for bash/zsh/fish. Generating from the command tree rather than writing a script by hand is what keeps completions from drifting away from the verbs they complete — the same reason `markdown-docs` renders the docs from that tree. Dispatched before PathArgs::resolve() for the same reason markdown-docs is: emitting a completion script needs none of the SWARMCTL_AUTHELIA_* deployment env vars, and requiring them would make the package's own build-time invocation fail — exactly where it runs. swarmctl leaves mkBinPackage for its own derivation, since the extractor installs a binary and nothing else.
This commit is contained in:
parent
0b1b08dfe6
commit
75f99ecafb
5 changed files with 72 additions and 1 deletions
|
|
@ -155,7 +155,27 @@ in
|
|||
# the one host that runs the controller, and belongs in that hive's
|
||||
# closure only. Kept a separate derivation rather than a second binary
|
||||
# in the daemon's package so a hive can pin one without the other.
|
||||
swarmctl = mkBinPackage "swarmctl" "hyperhive swarm-level operator CLI";
|
||||
#
|
||||
# Not `mkBinPackage`, because of the completions: they come from the
|
||||
# binary's own `completions <shell>` verb, which walks the live clap
|
||||
# tree, so they cannot drift from the actual verbs. Same shape as
|
||||
# `hivectlPkg` above.
|
||||
swarmctl =
|
||||
pkgs.runCommand "swarmctl"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.installShellFiles ];
|
||||
meta = {
|
||||
description = "hyperhive swarm-level operator CLI";
|
||||
mainProgram = "swarmctl";
|
||||
};
|
||||
}
|
||||
''
|
||||
install -Dm755 ${workspaceBuild}/bin/swarmctl $out/bin/swarmctl
|
||||
installShellCompletion --cmd swarmctl \
|
||||
--bash <("$out/bin/swarmctl" completions bash) \
|
||||
--zsh <("$out/bin/swarmctl" completions zsh) \
|
||||
--fish <("$out/bin/swarmctl" completions fish)
|
||||
'';
|
||||
|
||||
# Static build of the swarm-level UI shell — see ./swarm-ui.nix. Same
|
||||
# "swarm-scoped, not core-bundle" reasoning as swarm-controller/swarmctl
|
||||
|
|
|
|||
Loading…
Reference in a new issue