(root string)
| 56 | } |
| 57 | |
| 58 | func 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 | |
| 85 | func initProjectConfig(root string) (configInitResult, error) { |
| 86 | cfgPath := config.ConfigPath(root) |
no test coverage detected