Skip to content

Commit 37a1907

Browse files
JordanCoinclaude
andcommitted
Add --help and --version flags
- Add printUsage() for clean help output - Add version variable with ldflags injection - Update goreleaser to set version at build time 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8a96408 commit 37a1907

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ builds:
1313
env:
1414
- CGO_ENABLED=0
1515
ldflags:
16-
- -s -w
16+
- -s -w -X main.version={{.Version}}
1717
goos:
1818
- darwin
1919
- linux

main.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@ import (
1010
"github.com/JordanCoin/docmap/render"
1111
)
1212

13+
var version = "dev"
14+
1315
func main() {
1416
if len(os.Args) < 2 {
15-
fmt.Println("Usage: docmap <file.md|dir> [--section <name>] [--expand <name>] [--refs]")
17+
printUsage()
1618
os.Exit(1)
1719
}
1820

21+
// Check for help/version flags first
22+
for _, arg := range os.Args[1:] {
23+
switch arg {
24+
case "--help", "-h":
25+
printUsage()
26+
return
27+
case "--version", "-v":
28+
fmt.Printf("docmap %s\n", version)
29+
return
30+
}
31+
}
32+
1933
target := os.Args[1]
2034

2135
// Parse flags
@@ -115,3 +129,27 @@ func parseDirectory(dir string) []*parser.Document {
115129

116130
return docs
117131
}
132+
133+
func printUsage() {
134+
fmt.Println(`docmap - instant documentation structure for LLMs and humans
135+
136+
Usage:
137+
docmap <file.md|dir> [flags]
138+
139+
Examples:
140+
docmap . # All markdown files in directory
141+
docmap README.md # Single file deep dive
142+
docmap docs/ # Specific folder
143+
docmap README.md --section "API" # Filter to section
144+
docmap README.md --expand "API" # Show section content
145+
docmap . --refs # Show cross-references between docs
146+
147+
Flags:
148+
-s, --section <name> Filter to a specific section
149+
-e, --expand <name> Show full content of a section
150+
-r, --refs Show cross-references between markdown files
151+
-v, --version Print version
152+
-h, --help Show this help
153+
154+
More info: https://github.com/JordanCoin/docmap`)
155+
}

0 commit comments

Comments
 (0)