#311
gdtest_go_cli
OK
CONFIG
Go CLI project with cobra-style --help output
A pure Go CLI project (no Python module). The project has a go.mod and a stdlib-only CLI under cmd/hello/ that emits cobra-style --help output. Great Docs compiles the binary with 'go build', recurses through 'hello --help', 'hello greet --help', and 'hello version --help', and generates a CLI reference section in the site. On the CLI reference index you should see 'greet' and 'version' listed (with 'completion' and 'help' excluded). Each subcommand should have its own page with flags documented. The landing page comes from README.md. There is no API Reference section โ the site is driven entirely by the Go CLI.
Build Mode
● Has great-docs.yml
This package ships a pre-supplied config.
The great-docs init step is skipped and
great-docs build uses the spec-defined configuration directly.
Tests specific config options and their rendered output.
Dimensions
Z1 F6 G1 H7
Z1Go CLI (cobra-style --help)go_cli
F6No user guideuser_guide
G1README.mdlanding
H7No extrasextras
Source Files
cmd/
hello/
main.go
package main
import (
"fmt"
"os"
"strings"
)
// Minimal CLI that emits cobra-style --help output so great-docs CLI
// reference generation can be exercised without external Go dependencies.
const rootHelp = `A minimal Go CLI for testing great-docs documentation.
Usage:
hello [command]
Available Commands:
greet Print a personalised greeting
version Print the version
Flags:
--config string config file (default: hello.toml)
-h, --help help for hello
-v, --verbose enable verbose output
Use "hello [command] --help" for more information about a command.`
const greetHelp = `Print a personalised greeting to standard output.
Usage:
hello greet [flags]
Flags:
-h, --help help for greet
-n, --name string name to greet (default "World")
Global Flags:
--config string config file (default: hello.toml)
-v, --verbose enable verbose output`
const versionHelp = `Print the version string and exit.
Usage:
hello version [flags]
Flags:
-h, --help help for version
Global Flags:
--config string config file (default: hello.toml)
-v, --verbose enable verbose output`
func main() {
args := os.Args[1:]
isHelp := func(a []string) bool {
for _, arg := range a {
if arg == "--help" || arg == "-h" {
return true
}
}
return false
}
if len(args) == 0 || isHelp(args) {
sub := ""
for _, a := range args {
if !strings.HasPrefix(a, "-") {
sub = a
break
}
}
switch sub {
case "greet":
fmt.Println(greetHelp)
case "version":
fmt.Println(versionHelp)
default:
fmt.Println(rootHelp)
}
return
}
switch args[0] {
case "greet":
name := "World"
for i, a := range args[1:] {
if (a == "--name" || a == "-n") && i+2 < len(args) {
name = args[i+2]
}
}
fmt.Printf("Hello, %s!\n", name)
case "version":
fmt.Println("hello 0.1.0")
default:
fmt.Fprintf(os.Stderr, "unknown command: %s\n", args[0])
os.Exit(1)
}
}README.md
# hello A minimal Go CLI for testing great-docs Go CLI documentation generation. ## Installation ```bash go install github.com/posit-dev/great-docs/testdata/gdtest_go_cli/cmd/hello@latest ``` ## Usage ```bash hello greet --name World hello version ```
go.mod
module github.com/posit-dev/great-docs/testdata/gdtest_go_cli go 1.21
great-docs.yml
project_type: go go_cli: enabled: true mcp: enabled: false