MCPcopy Create free account
hub / github.com/JordanCoin/codemap / configInit

Function configInit

cmd/config.go:58–83  ·  view source on GitHub ↗
(root string)

Source from the content-addressed store, hash-verified

56}
57
58func configInit(root string) {
59 result, err := initProjectConfig(root)
60 if errors.Is(err, errConfigExists) {
61 cfgPath := config.ConfigPath(root)
62 fmt.Fprintf(os.Stderr, "Config already exists: %s\n", cfgPath)
63 fmt.Fprintln(os.Stderr, "Use 'codemap config show' to view it, or edit directly.")
64 os.Exit(1)
65 }
66 if err != nil {
67 fmt.Fprintf(os.Stderr, "Error creating config: %v\n", err)
68 os.Exit(1)
69 }
70
71 fmt.Printf("Created %s\n", result.Path)
72 fmt.Println()
73 if len(result.TopExts) == 0 {
74 fmt.Println("No code extensions detected — wrote empty config.")
75 } else {
76 fmt.Printf(" only: %s\n", strings.Join(result.TopExts, ", "))
77 if result.TotalFiles > 0 {
78 fmt.Printf(" (%d of %d files)\n", result.MatchedFiles, result.TotalFiles)
79 }
80 }
81 fmt.Println()
82 fmt.Println("Edit the file to add 'exclude' patterns or adjust 'depth'.")
83}
84
85func initProjectConfig(root string) (configInitResult, error) {
86 cfgPath := config.ConfigPath(root)

Callers 1

RunConfigFunction · 0.85

Calls 2

ConfigPathFunction · 0.92
initProjectConfigFunction · 0.85

Tested by

no test coverage detected