feat(cli): add fix-order command for sorting README entries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Julien Bisconti
2026-03-31 19:37:48 +02:00
parent f81eea2496
commit 903a700510

View File

@@ -44,6 +44,7 @@ func main() {
root.AddCommand( root.AddCommand(
versionCmd(), versionCmd(),
lintCmd(), lintCmd(),
fixOrderCmd(),
checkCmd(), checkCmd(),
healthCmd(), healthCmd(),
buildCmd(), buildCmd(),
@@ -314,6 +315,25 @@ func buildHealthReportIssueBody(report string, healthErr error) string {
return b.String() return b.String()
} }
func fixOrderCmd() *cobra.Command {
return &cobra.Command{
Use: "fix-order",
Short: "Sort README entries alphabetically within each section",
RunE: func(cmd *cobra.Command, args []string) error {
count, err := linter.SortFile(readmePath)
if err != nil {
return fmt.Errorf("fix-order: %w", err)
}
if count == 0 {
fmt.Println("Already sorted, no changes needed")
} else {
fmt.Printf("Sorted %d lines in %s\n", count, readmePath)
}
return nil
},
}
}
func lintCmd() *cobra.Command { func lintCmd() *cobra.Command {
var fix bool var fix bool
cmd := &cobra.Command{ cmd := &cobra.Command{