Skip to content

Commit 350359a

Browse files
authored
Merge pull request #9 from continuedev/init-already-exists
Update init command to warn when rules.json already exists
2 parents faf6d0a + 3b33141 commit 350359a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

cmd/init.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ This creates the necessary directory structure and an empty rules.json file.`,
2121
RunE: func(cmd *cobra.Command, args []string) error {
2222
color.Cyan("Initializing rules with format: %s", format)
2323

24-
// Check if rules.json doesn't exist
24+
// Check if rules.json already exists
2525
rulesJSONPath, err := formats.GetRulesJSONPath(format)
2626
if err != nil {
2727
return fmt.Errorf("failed to get rules.json path: %w", err)
2828
}
2929

30-
if _, err := os.Stat(rulesJSONPath); os.IsNotExist(err) {
30+
if _, err := os.Stat(rulesJSONPath); err == nil {
31+
// rules.json already exists - warn the user
32+
color.Yellow("Warning: %s already exists", rulesJSONPath)
33+
color.Yellow("Initialization will skip creating rules.json but may create/update directory structure")
34+
} else if os.IsNotExist(err) {
3135
// Check for any top-level folder of the structure ".{folder-name}/rules"
3236
formatFolders, err := formats.FindRulesFormats()
3337
if err == nil && len(formatFolders) > 0 {

0 commit comments

Comments
 (0)