Skip to content

Commit 46b59ac

Browse files
committed
fix: remove --all flag from render command
1 parent d6be240 commit 46b59ac

2 files changed

Lines changed: 24 additions & 48 deletions

File tree

cmd/render.go

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@ import (
77
"path/filepath"
88
"strings"
99

10-
"rules-cli/internal/config"
1110
"rules-cli/internal/formats"
1211

1312
"github.com/spf13/cobra"
1413
)
1514

16-
var (
17-
renderAll bool
18-
)
19-
2015
// renderCmd represents the render command
2116
var renderCmd = &cobra.Command{
2217
Use: "render [format]",
@@ -27,23 +22,14 @@ Creates .{format}/rules/ directory and copies all rules from the default locatio
2722
Example: ` rules render cursor
2823
rules render continue`,
2924
RunE: func(cmd *cobra.Command, args []string) error {
30-
var formatList []string
31-
32-
if renderAll {
33-
// Get all formats from config
34-
cfg, err := config.LoadConfig()
35-
if err != nil {
36-
return fmt.Errorf("failed to load config: %w", err)
37-
}
38-
formatList = cfg.Formats
39-
if len(formatList) == 0 {
40-
return fmt.Errorf("no formats specified in config")
41-
}
42-
} else {
43-
if len(args) < 1 {
44-
return fmt.Errorf("format is required when --all flag is not used")
45-
}
46-
formatList = []string{args[0]}
25+
if len(args) < 1 {
26+
return fmt.Errorf("format is required")
27+
}
28+
29+
formatName := args[0]
30+
31+
if formatName == "default" {
32+
return fmt.Errorf("cannot render to default format as it is the source")
4733
}
4834

4935
// Get the source directory
@@ -56,33 +42,26 @@ Creates .{format}/rules/ directory and copies all rules from the default locatio
5642
return fmt.Errorf("source directory %s does not exist", sourceDir)
5743
}
5844

59-
for _, formatName := range formatList {
60-
if formatName == "default" {
61-
fmt.Println("Skipping default format as it is the source")
62-
continue
63-
}
64-
65-
fmt.Printf("Rendering rules to %s format...\n", formatName)
66-
67-
// Get target directory
68-
targetDir, err := formats.GetRulesDirectory(formatName)
69-
if err != nil {
70-
return fmt.Errorf("failed to get target directory for format %s: %w", formatName, err)
71-
}
72-
73-
// Create target directory if it doesn't exist
74-
if err := os.MkdirAll(targetDir, 0755); err != nil {
75-
return fmt.Errorf("failed to create target directory %s: %w", targetDir, err)
76-
}
45+
fmt.Printf("Rendering rules to %s format...\n", formatName)
46+
47+
// Get target directory
48+
targetDir, err := formats.GetRulesDirectory(formatName)
49+
if err != nil {
50+
return fmt.Errorf("failed to get target directory for format %s: %w", formatName, err)
51+
}
7752

78-
// Copy rules from source to target
79-
if err := copyDir(sourceDir, targetDir); err != nil {
80-
return fmt.Errorf("failed to copy rules to target directory: %w", err)
81-
}
53+
// Create target directory if it doesn't exist
54+
if err := os.MkdirAll(targetDir, 0755); err != nil {
55+
return fmt.Errorf("failed to create target directory %s: %w", targetDir, err)
56+
}
8257

83-
fmt.Printf("Successfully rendered rules to %s format\n", formatName)
58+
// Copy rules from source to target
59+
if err := copyDir(sourceDir, targetDir); err != nil {
60+
return fmt.Errorf("failed to copy rules to target directory: %w", err)
8461
}
8562

63+
fmt.Printf("Successfully rendered rules to %s format\n", formatName)
64+
8665
return nil
8766
},
8867
}
@@ -159,5 +138,4 @@ func copyFile(src, dst string) error {
159138

160139
func init() {
161140
rootCmd.AddCommand(renderCmd)
162-
renderCmd.Flags().BoolVar(&renderAll, "all", false, "Render to all formats specified in config")
163141
}

spec/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ rules render continue
165165

166166
- **Args**:
167167
- Name of format to render rules to (e.g., "foo", "continue")
168-
- **Flags**:
169-
- `--all`: Renders to all formats specified in config
170168
- **Behavior**:
171169
- Creates `.{format}/rules/` directory (e.g., `.foo/rules/`)
172170
- Copies all rules from the default location (`.rules/`) to the target format location

0 commit comments

Comments
 (0)