-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
73 lines (67 loc) · 1.79 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/skelouse/code-to-gpt/parser"
"github.com/urfave/cli/v3"
)
func main() {
cmd := &cli.Command{
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "clipboard",
Usage: "does not work with split-files",
Aliases: []string{"c"},
},
&cli.BoolFlag{
Name: "quiet",
Usage: "silences success and tree printout",
Aliases: []string{"q"},
},
&cli.StringSliceFlag{
Name: "include",
Usage: "Include files matching glob patterns",
Aliases: []string{"i"},
},
&cli.StringSliceFlag{
Name: "exclude",
Usage: "Exclude files matching glob patterns",
Aliases: []string{"e"},
},
&cli.IntFlag{
Name: "max-size",
Usage: "Maximum total size of files to process (in bytes)",
Value: 2 * 1024 * 1024, // Default to 2MB
},
&cli.BoolFlag{
Name: "split-files",
Aliases: []string{"s"},
},
},
Action: func(ctx *cli.Context) error {
// Check for unexpected positional arguments
if ctx.Args().Len() > 0 {
if len(ctx.StringSlice("include")) > 0 || len(ctx.StringSlice("exclude")) > 0 {
return fmt.Errorf(
"unexpected arguments: %v\nThis may be due to shell glob expansion.\nPlease quote your glob patterns to prevent shell expansion.\nExample: --include \"**/*.js\"",
ctx.Args().Slice())
}
return fmt.Errorf("arguments not supported: %s", ctx.Args().Slice())
}
return parser.Run(parser.Options{
SplitFiles: ctx.Bool("split-files"),
Clipboard: ctx.Bool("clipboard"),
Include: ctx.StringSlice("include"),
Exclude: ctx.StringSlice("exclude"),
Quiet: ctx.Bool("quiet"),
MaxSize: ctx.Int("max-size"),
})
},
}
err := cmd.Run(context.Background(), os.Args)
if err != nil {
log.Fatal(err)
}
}