CodeVetter · Repo Unpack · System map
spf13/cobra
The runtime is a library embedded in a consuming application's executable. Command owns the tree, flags, callbacks, context, and streams; separate generators consume that model. Persistent artifacts are explicitly generated files, while execution state lives in memory. Repository automation supplies testing, linting, license checking, dependency updates, and PR labeling.
- The public application entrypoints are Command.Execute, ExecuteC, ExecuteContext, and ExecuteContextC; the user guide places the application's main function outside the library.
- Command combines command metadata, argument validation, lifecycle callbacks, pflag sets, parent/child links, context, and configurable IO streams.
- go.mod declares github.com/spf13/cobra with Go 1.15 and dependencies on pflag, mousetrap, go-md2man/v2, and YAML v3.
- The doc package renders the Command model through writer APIs and directory-based tree generators; Markdown uses os.Create, man uses md2man.Render, and YAML uses yaml.Marshal.
- Platform build tags select an unset pre-execution hook on non-Windows and an Explorer-launch detection hook using mousetrap on Windows.
- Makefile exposes formatting, lint, go test, and richgo test targets; both test targets depend on install_deps, which runs go get -v ./....
- Test CI defines license and lint jobs, Ubuntu/macOS matrices for Go 1.17–1.24, and a Windows MSYS2 job; Unix and Windows jobs invoke make richtest.
- PR labeling runs actions/labeler on pull_request_target with PR-write permission, while Dependabot schedules weekly Go-module and GitHub Actions updates.