Skip to content

Commit 83ec8be

Browse files
committed
feat: adds format
1 parent 1876434 commit 83ec8be

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

cmd/formats.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"rules-cli/internal/formats"
6+
7+
"github.com/spf13/cobra"
8+
)
9+
10+
// formatsCmd represents the formats command
11+
var formatsCmd = &cobra.Command{
12+
Use: "formats",
13+
Short: "List all available render formats",
14+
Long: `List all supported render formats for the 'rules render' command.
15+
Each format represents a different AI code assistant platform with specific
16+
folder structures and file extensions.`,
17+
Example: ` rules formats`,
18+
RunE: func(cmd *cobra.Command, args []string) error {
19+
fmt.Println("Available render formats:")
20+
fmt.Println()
21+
22+
formatList := formats.GetAllFormats()
23+
for _, format := range formatList {
24+
if format.IsSingleFile {
25+
fmt.Printf("%-10s - %s (%s)\n", format.Name, format.SingleFilePath, format.Description)
26+
} else {
27+
fmt.Printf("%-10s - %s/*%s (%s)\n", format.Name, format.DirectoryPrefix, format.FileExtension, format.Description)
28+
}
29+
}
30+
31+
fmt.Println()
32+
fmt.Println("Usage: rules render <format>")
33+
34+
return nil
35+
},
36+
}
37+
38+
func init() {
39+
rootCmd.AddCommand(formatsCmd)
40+
}

internal/formats/formats.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Format struct {
1414
FileExtension string
1515
IsSingleFile bool
1616
SingleFilePath string
17+
Description string
1718
}
1819

1920
// GetFormat returns a Format for the given format name
@@ -25,6 +26,7 @@ func GetFormat(formatName string) Format {
2526
DirectoryPrefix: ".rules",
2627
FileExtension: ".md",
2728
IsSingleFile: false,
29+
Description: "Default rules format",
2830
}
2931
}
3032

@@ -36,20 +38,23 @@ func GetFormat(formatName string) Format {
3638
DirectoryPrefix: ".continue/rules",
3739
FileExtension: ".md",
3840
IsSingleFile: false,
41+
Description: "Continue Dev rules",
3942
}
4043
case "cursor":
4144
return Format{
4245
Name: "cursor",
4346
DirectoryPrefix: ".cursor/rules",
4447
FileExtension: ".mdc",
4548
IsSingleFile: false,
49+
Description: "Cursor rules",
4650
}
4751
case "windsurf":
4852
return Format{
4953
Name: "windsurf",
5054
DirectoryPrefix: ".windsurf/rules",
5155
FileExtension: ".md",
5256
IsSingleFile: false,
57+
Description: "Windsurf rules",
5358
}
5459
case "claude":
5560
return Format{
@@ -58,13 +63,15 @@ func GetFormat(formatName string) Format {
5863
FileExtension: ".md",
5964
IsSingleFile: true,
6065
SingleFilePath: "CLAUDE.md",
66+
Description: "Claude Code single file",
6167
}
6268
case "copilot":
6369
return Format{
6470
Name: "copilot",
6571
DirectoryPrefix: ".github/instructions",
6672
FileExtension: ".instructions.md",
6773
IsSingleFile: false,
74+
Description: "GitHub Copilot instructions",
6875
}
6976
case "codex":
7077
return Format{
@@ -73,20 +80,23 @@ func GetFormat(formatName string) Format {
7380
FileExtension: ".md",
7481
IsSingleFile: true,
7582
SingleFilePath: "AGENT.md",
83+
Description: "Codex single file",
7684
}
7785
case "cline":
7886
return Format{
7987
Name: "cline",
8088
DirectoryPrefix: ".clinerules",
8189
FileExtension: ".md",
8290
IsSingleFile: false,
91+
Description: "Cline rules",
8392
}
8493
case "cody":
8594
return Format{
8695
Name: "cody",
8796
DirectoryPrefix: ".sourcegraph",
8897
FileExtension: ".rule.md",
8998
IsSingleFile: false,
99+
Description: "Sourcegraph Cody rules",
90100
}
91101
case "amp":
92102
return Format{
@@ -95,6 +105,7 @@ func GetFormat(formatName string) Format {
95105
FileExtension: ".md",
96106
IsSingleFile: true,
97107
SingleFilePath: "AGENT.md",
108+
Description: "Amp single file",
98109
}
99110
default:
100111
// For any other format, use .<format>/rules
@@ -103,6 +114,7 @@ func GetFormat(formatName string) Format {
103114
DirectoryPrefix: fmt.Sprintf(".%s/rules", formatName),
104115
FileExtension: ".md",
105116
IsSingleFile: false,
117+
Description: fmt.Sprintf("%s rules", formatName),
106118
}
107119
}
108120
}
@@ -197,3 +209,19 @@ func RenderRules(sourceDir string, targetFormat Format) error {
197209
// Use the transformer to process the rule files
198210
return ProcessRuleFiles(sourceDir, targetFormat)
199211
}
212+
213+
// GetAllFormats returns a list of all supported formats
214+
func GetAllFormats() []Format {
215+
formats := []Format{
216+
GetFormat("continue"),
217+
GetFormat("cursor"),
218+
GetFormat("windsurf"),
219+
GetFormat("claude"),
220+
GetFormat("copilot"),
221+
GetFormat("codex"),
222+
GetFormat("cline"),
223+
GetFormat("cody"),
224+
GetFormat("amp"),
225+
}
226+
return formats
227+
}

spec/commands/formats.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `rules formats`
2+
3+
Lists all available render formats for the `rules render` command.
4+
5+
## Usage
6+
7+
```bash
8+
rules formats
9+
```
10+
11+
## Args
12+
13+
None
14+
15+
## Behavior
16+
17+
- Displays a list of all supported render formats
18+
- Shows the target directory/file and description for each format
19+
- Provides usage example for the `rules render` command
20+
- Does not modify any files

0 commit comments

Comments
 (0)