-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
519 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= | ||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= | ||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= | ||
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= | ||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= | ||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func ApplyCommand() *cli.Command { | ||
return &cli.Command{ | ||
Name: "apply", | ||
Usage: "Add annotations to files", | ||
Flags: append(commonFlags, | ||
&cli.BoolFlag{ | ||
Name: "dry-run", | ||
Aliases: []string{"n"}, | ||
Usage: "Show what would be done without making changes", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "recursive", | ||
Aliases: []string{"r"}, | ||
Usage: "Process directories recursively", | ||
Value: true, | ||
}, | ||
), | ||
Action: runApply, | ||
} | ||
} | ||
|
||
func runApply(c *cli.Context) error { | ||
proc, err := createProcessor(c) | ||
if err != nil { | ||
return fmt.Errorf("failed to initialize processor: %w", err) | ||
} | ||
|
||
files, err := proc.ListFiles() | ||
if err != nil { | ||
return fmt.Errorf("failed to list files: %w", err) | ||
} | ||
|
||
if c.Bool("dry-run") { | ||
log.Printf("Would process %d files in %s", len(files), c.String("dir")) | ||
for _, file := range files { | ||
log.Printf("Would annotate: %s", file) | ||
} | ||
return nil | ||
} | ||
|
||
if err := proc.Process(); err != nil { | ||
return fmt.Errorf("failed to process files: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func CleanCommand() *cli.Command { | ||
return &cli.Command{ | ||
Name: "clean", | ||
Usage: "Remove annotations from files", | ||
Flags: append(commonFlags, | ||
&cli.BoolFlag{ | ||
Name: "dry-run", | ||
Aliases: []string{"n"}, | ||
Usage: "Show what would be done without making changes", | ||
}, | ||
), | ||
Action: runClean, | ||
} | ||
} | ||
|
||
func runClean(c *cli.Context) error { | ||
proc, err := createProcessor(c) | ||
if err != nil { | ||
return fmt.Errorf("failed to initialize processor: %w", err) | ||
} | ||
|
||
files, err := proc.ListFiles() | ||
if err != nil { | ||
return fmt.Errorf("failed to list files: %w", err) | ||
} | ||
|
||
if c.Bool("dry-run") { | ||
log.Printf("Would clean %d files in %s", len(files), c.String("dir")) | ||
for _, file := range files { | ||
log.Printf("Would clean: %s", file) | ||
} | ||
return nil | ||
} | ||
|
||
if err := proc.Clean(); err != nil { | ||
return fmt.Errorf("failed to clean files: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func Commands() []*cli.Command { | ||
return []*cli.Command{ | ||
ApplyCommand(), | ||
CleanCommand(), | ||
ListCommand(), | ||
StatsCommand(), | ||
} | ||
} | ||
|
||
var commonFlags = []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "dir", | ||
Aliases: []string{"d"}, | ||
Usage: "Directory to process", | ||
Value: ".", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "types", | ||
Aliases: []string{"t"}, | ||
Usage: "Comma-separated list of file types to process", | ||
Value: "go,py,js,jsx,ts,tsx", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "verbose", | ||
Aliases: []string{"V"}, | ||
Usage: "Enable verbose logging", | ||
}, | ||
} |
Oops, something went wrong.