Skip to content

Ship shell completions and a man page - #41

Merged
Huseynteymurzade28 merged 1 commit into
mainfrom
completions
Sep 24, 2026
Merged

Huseynteymurzade28 merged 1 commit into
mainfrom
completions

Conversation

@Huseynteymurzade28

Copy link
Copy Markdown
Owner

Adds --completions SHELL (bash, zsh, fish, PowerShell, elvish) and a hidden --man. Both are generated from the Cli definition with clap_complete and clap_mangen.

  • In the binary, not in an xtask. An xtask was the issue's suggestion, but it would leave the AUR package, which builds from the crates.io tarball, with no way to generate the files. The flags add one extra crate (roff, MIT/Apache, MSRV 1.85).
  • Tests. Every visible flag must appear in every shell's script and in the man page, so a new flag can't be left out.
  • Release workflow. A new extras job generates the files once, and every archive carries completions/ and man/. The release job now downloads only the per-target artifacts, so gh release create dist/* doesn't hit the directories.
  • The README has a Shell completions and man page section and the help block now matches -h. The changelog has an entry.

Checked locally: fish completes flags and their values, and the man page renders under groff -ww with no warnings. A manual run of the release workflow on this branch checks the archive layout.

Closes #38

The command line has grown to six flags, three of them with a fixed set of
values, and none of it completed in a shell. There was no man page either,
so `man pokeductor` found nothing on a system that installed it from a
package. clap already held all of it — the values come from the enums and
the help text is written on `Cli` — so both only had to be asked for.

`--completions SHELL` prints the script for bash, zsh, fish, PowerShell or
elvish, and a hidden `--man` prints the page as roff. They come out of the
binary rather than a build script or an xtask, which is what #38 suggested
to keep them out of the dependency tree. The cost of that turned out to be
one crate, `roff`, and the xtask route would have left the AUR package with
nothing to generate them from, since it builds from the crates.io tarball
where an xtask does not exist. A flag works wherever the crate builds. Both
are `exclusive`, as the other print-and-exit commands effectively are.

Tests pin the part that could drift: every visible long flag appears in
every shell's script and in the man page, and `--man` stays out of it.

The release workflow generates them once, in a job of its own, and every
archive carries `completions/` and `man/`. Once rather than per target
because the text is the same everywhere, and because the Intel Mac build
cross-compiles on an ARM runner and could not run its own binary to ask.
The release job now downloads only the per-target artifacts, since the
extras' directories under `dist/` would make `gh release create dist/*`
fail.

`print` moved to `cli.rs` so `--json` and the generators share the one
place that ends quietly on a closed pipe.

Closes #38
@Huseynteymurzade28
Huseynteymurzade28 merged commit 219817e into main Sep 24, 2026
7 checks passed
@Huseynteymurzade28
Huseynteymurzade28 deleted the completions branch September 24, 2026 13:11
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.

Ship shell completions and a man page

1 participant