refactor(docs)!: rename CLI binary to corestack-docs
go install names binaries after the directory, so cmd/docs installed an ambiguous `docs` binary into $GOBIN that could clobber or be clobbered by other tools. Move it to cmd/corestack-docs, matching corestack-goose, and update goreleaser, CI, docs and usage text. Accepted ADRs keep their text and gain a dated rename note. BREAKING CHANGE: `go install go.auvem.com/corestack/cmd/docs@latest` stops resolving after the next tag; use cmd/corestack-docs. @v0.1.0 still installs the old `docs` binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #17.
This commit is contained in:
1 parent
fe44cac3a2
commit
0034a561ba
10 files changed
+31
-25
No files matched your search
@@ -0,0 +1,66 @@
|
||||
// Command corestack-docs creates and checks ADR and plan records. See docs/docs-format.md.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"go.auvem.com/corestack/internal/docs"
|
||||
)
|
||||
|
||||
const usage = `usage:
|
||||
corestack-docs new adr|plan "Title"
|
||||
corestack-docs check [--root DIR]
|
||||
`
|
||||
|
||||
func main() { os.Exit(run(os.Args[1:], os.Stdout, os.Stderr, time.Now())) }
|
||||
|
||||
// run returns the exit status: 0 success, 1 problems or failure, 2 usage error.
|
||||
func run(args []string, stdout, stderr io.Writer, now time.Time) int {
|
||||
if len(args) == 0 {
|
||||
fmt.Fprint(stderr, usage)
|
||||
return 2
|
||||
}
|
||||
switch args[0] {
|
||||
case "new":
|
||||
if len(args) != 3 || (args[1] != "adr" && args[1] != "plan") {
|
||||
fmt.Fprint(stderr, usage)
|
||||
return 2
|
||||
}
|
||||
path, err := docs.New(".", args[1], args[2], now)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "corestack-docs: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintln(stdout, path)
|
||||
return 0
|
||||
case "check":
|
||||
fs := flag.NewFlagSet("corestack-docs check", flag.ContinueOnError)
|
||||
fs.SetOutput(stderr)
|
||||
root := fs.String("root", ".", "repository root")
|
||||
if err := fs.Parse(args[1:]); err != nil || fs.NArg() != 0 {
|
||||
if fs.NArg() != 0 {
|
||||
fmt.Fprint(stderr, usage)
|
||||
}
|
||||
return 2
|
||||
}
|
||||
res, err := docs.Check(*root)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "corestack-docs: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
for _, p := range res.Problems {
|
||||
fmt.Fprintln(stdout, p)
|
||||
}
|
||||
if len(res.Problems) > 0 {
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintf(stdout, "ok: %d records checked\n", res.Records)
|
||||
return 0
|
||||
}
|
||||
fmt.Fprint(stderr, usage)
|
||||
return 2
|
||||
}
|
||||
Reference in new issue
Block a user