Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Generate the CLI reference and help from one command table

f380ab70420ddf24f68931fa26e1288aff4acca6 · Keenan Nemetz · 23d ago · parent c284cb2c

Generate the CLI reference and help from one command table

The CLI documented itself four ways: a usage string per command group, inline
"usage: vole ..." strings in error paths, a per-group accepted-flag list, and
docs/cli.md, which was hand-written and had already drifted. `vole help` never
listed `run list`, `run show` or `run logs`, though all three exist and
`vole run -h` documented them; the reference listed them.

Each group now declares its subcommands, its flags (with argument and a one-line
description), its notes and its links in one table, in the file that parses it.
Three things render from that table:

  - `vole help` and `vole <group> -h`, which gain an Options section and now list
    every command and every flag;
  - `vole help --markdown`, which writes docs/cli.md;
  - `checkAllowed`, which refuses a flag the subcommand does not document — the
    per-group flag lists are gone, so the parser and the docs are one list.

verify regenerates docs/cli.md and fails on any difference, so the page cannot go
stale. cmd/vole/help_test.go checks that every flag has a description, that every
parsed flag is documented by some subcommand, that each subcommand accepts exactly
the flags it lists, and that the committed reference matches the binary.

Closes: 01M7359KQ6Z8W91N8WNWVV120B

cmd/vole/attach.go +5−14

@@ -22,27 +22,18 @@ import (
22 22 "rodent.software/vole/metadata"
23 23 )
24 24
25 func releaseAttachUsage() string {
26 return `usage: vole release attach <tag> <file>... [--remote <name>]
27
28 Uploads each file over SSH into the instance's object store and records it on
29 the metadata branch as releases/<tag>/<name>. Nothing is published until the
30 pointer is pushed, and a pointer whose bytes are missing is refused by the
31 server, so attach after ` + "`git push --follow-tags`" + `, not before.`
32 }
33
34 25 func cmdReleaseAttach(args []string) error {
35 f, err := parseFlags(args,
36 flagSpec{long: "remote"},
37 flagSpec{long: "help", short: "h", boolean: true},
38 )
26 f, err := parseFlags(args, releaseGroup.Flags...)
39 27 if err != nil {
40 28 return err
41 29 }
42 30 if f.help {
43 fmt.Println(releaseAttachUsage())
31 fmt.Print(renderHelpText(releaseGroup))
44 32 return nil
45 33 }
34 if err := f.checkAllowed("vole release attach"); err != nil {
35 return err
36 }
46 37 if len(f.rest) < 2 {
47 38 return usageErr{msg: "usage: vole release attach <tag> <file>... [--remote <name>]"}
48 39 }