Skip to content

Conversation

@GunniBusch
Copy link
Contributor

@GunniBusch GunniBusch commented Jan 1, 2026

First, I want to give credit to @givensuman providing the excellent base implementation of cobra in #26 !

Content

This PR brings mainly automatic generation of man/markdown/etc docs of the cli. Don't confuse this with proper docks, since these docks are only the bare low level manpage docks. (including rendering in markdown and more).

Why?

The biggest reason why I did this, is so that changes to the cli ar erefelcteed in the already existing witr.1file. The biggest benefit would be to automatically generate this via a cicd pipeline (eg the release one).

Changes

I would like to give the word to copilot:

This pull request refactors the CLI entrypoint for the witr tool to improve maintainability and adds automated documentation generation for the CLI. The main logic for the CLI is moved from cmd/witr/main.go into a new cmd/root.go file, and a new tool is introduced to generate up-to-date CLI documentation in both Markdown and man page formats. Documentation files are also added for user reference.

CLI Refactor and Entrypoint Changes:

  • Moved all CLI logic and command setup from cmd/witr/main.go into a new cmd/root.go file, organizing the code and making it easier to maintain and extend. The new structure uses a dedicated function to set version/build info and exposes the root command for use elsewhere. (cmd/root.go, cmd/witr/main.go) [1] [2] [3] (No meaningful code changes compared to Migrate CLI to use Cobra #26)

Automated CLI Documentation Generation:

  • Added a new tool internal/tools/docgen/main.go that uses Cobra's doc generation features to output Markdown, man, or reStructuredText documentation for the CLI, supporting optional YAML front matter for Markdown. (internal/tools/docgen/main.go)
  • Updated go.mod to add required dependencies for documentation generation (Cobra, go-md2man, blackfriday, etc.). (go.mod)

Documentation Files:

  • Added generated CLI documentation in Markdown (docs/cli/witr.md) and man page (docs/cli/witr.1) formats, including usage, options, and examples for the witr command. [1] [2]

Other:

  • Added a reference to the new CLI entrypoint in main.go for clarity. (main.go)

TODO

  • Add ci/cd doc generation
  • Add shell completion to brew

@GunniBusch
Copy link
Contributor Author

@pranshuparmar for the brew file to include the shell completion, you would need to merge staging into main such that brew is autobumbed

@pranshuparmar pranshuparmar merged commit 5aaa67c into pranshuparmar:staging Jan 2, 2026
5 checks passed
@pranshuparmar pranshuparmar mentioned this pull request Jan 2, 2026
@pranshuparmar
Copy link
Owner

@GunniBusch Changes are merged to main.

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.

2 participants