Skip to content

Generated CLI reference and man pages from cobra #56

Closed

Description

@dataGriff

Why

docs/cli.md is hand-written and already 470 lines; every new flag needs a matching edit and nothing checks they agree. cobra can generate Markdown and man pages from the command tree, which also gives the deb/rpm/Homebrew packages something to install under man/.

What

  • A hidden apic docs --format markdown|man --out <dir> command using github.com/spf13/cobra/doc (a separate module from cobra; measure the binary and, if it is too heavy, keep the generator under scripts/ instead).
  • docs/cli.md keeps its hand-written top (targets, exit codes, JSON shapes) and gains a generated "Commands and flags" section produced by task docs:cli; CI fails if the committed file is stale (task docs:cli && git diff --exit-code).
  • goreleaser ships man/apic*.1 in the archives and the nfpm packages install them; the Homebrew formula installs them and the completions.
  • Housekeeping while here: internal/cli/inspect.go holds list, describe, curl, env, session and validate but there is no inspect command; split or rename so the file name matches the contents (AGENTS.md layout entry updated).

Where

internal/cli/docs.go, internal/cli/root.go, Taskfile.yml, .github/workflows/ci.yml, .goreleaser.yaml, docs/cli.md.

Docs

docs/cli.md (structure), AGENTS.md ("New commands need…" rule mentions the generator), CONTRIBUTING.md.

Tests

A test that the generated Markdown for run contains every flag the command registers; the CI staleness check.

Activity

  1. dataGriff commented on Sep 24, 2026

    @dataGriff
    OwnerAuthor

    Done in #114 (38f4eb1). scripts/clidocs generates the "Commands and flags" section at the end of docs/cli.md (task docs:cli); a test fails when it is stale. -man <dir> writes roff man pages (task man), which goreleaser generates and ships in man/ in every archive, ready for the nfpm packages (#72) and the Homebrew formula (#57).


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions