feat: create cli docs and completion #79
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
witrtool to improve maintainability and adds automated documentation generation for the CLI. The main logic for the CLI is moved fromcmd/witr/main.gointo a newcmd/root.gofile, 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:
cmd/witr/main.gointo a newcmd/root.gofile, 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:
internal/tools/docgen/main.gothat 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)go.modto add required dependencies for documentation generation (Cobra, go-md2man, blackfriday, etc.). (go.mod)Documentation Files:
docs/cli/witr.md) and man page (docs/cli/witr.1) formats, including usage, options, and examples for thewitrcommand. [1] [2]Other:
main.gofor clarity. (main.go)TODO