Skip to content

Generate man page via cobra/doc and include in GoReleaser archives #17

@oksaumya

Description

@oksaumya

Summary

optiqor has no man page. Cobra ships a doc package (github.com/spf13/cobra/doc) that can generate a complete man page tree from any Cobra command tree. Packaging man pages in releases is a low-effort, high-signal quality indicator for CLI tools.

What to do

  1. Add a build-time generator script cmd/gendoc/main.go (not part of the main binary):
    //go:build ignore
    package main
    
    import (
        "github.com/spf13/cobra/doc"
        optiqor "github.com/optiqor/optiqor-cli/cmd/optiqor"
    )
    
    func main() {
        doc.GenManTree(optiqor.RootCmd, &doc.GenManHeader{
            Title:   "OPTIQOR",
            Section: "1",
        }, "./man")
    }
    This requires exporting RootCmd from cmd/optiqor/main.go (currently unexported as rootCmd).
  2. Add a make man target that runs go run cmd/gendoc/main.go and writes to man/.
  3. Update .goreleaser.yaml to include man/*.1 files in the Linux archives.

Acceptance criteria

  • make man generates man/optiqor.1 (and sub-pages for each subcommand).
  • man ./man/optiqor.1 renders without errors.
  • Man files are included in the GoReleaser Linux archive.
  • make lint test passes.

Why this is a good first issue

  • No new runtime dependencies (cobra/doc is already transitively available).
  • Self-contained: cmd/gendoc/main.go is a separate binary, so there is zero risk of touching the main binary.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions