-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
140 lines (133 loc) · 3.24 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package main
import (
"context"
"log"
"os"
"github.com/duckonomy/parkour/cmd"
"github.com/urfave/cli/v3"
)
func main() {
var pathFlag string
// TODO: Load Config as well and pass in to LoadState
if err := cmd.Init(); err != nil {
log.Fatal(err)
}
command := &cli.Command{
Name: "pd",
Usage: "project root finder",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Usage: "Project path",
Destination: &pathFlag,
},
},
Commands: []*cli.Command{
{
Name: "list",
Aliases: []string{"l"},
Usage: "list projects",
Action: func(ctx context.Context, command *cli.Command) error {
cmd.List()
return nil
},
},
{
Name: "add",
Aliases: []string{"a"},
Usage: "add project",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.Add(command.Args().Get(0))
},
},
{
Name: "remove",
Aliases: []string{"r"},
Usage: "remove project",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.Remove(command.Args().Get(0))
},
},
{
Name: "exec",
Usage: "Execute a command with arguments",
SkipFlagParsing: true,
ArgsUsage: "[PATH] COMMAND [ARGS...]",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.Exec(pathFlag, command.Args().Slice())
},
},
{
Name: "run",
Aliases: []string{"ru"},
Usage: "run project command",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.Run(command.Args().Get(0))
},
},
{
Name: "find",
Usage: "find project",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.FindProject()
},
},
{
Name: "find-file",
Usage: "find file",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.FindFile(command.Args().Get(0))
},
},
{
Name: "grep-file",
Usage: "grep file",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.GrepFile(command.Args().Get(0))
},
},
{
Name: "update",
Aliases: []string{"u"},
Usage: "update project",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.Update(command.Args().Get(0))
},
},
{
Name: "blacklist",
Aliases: []string{"b"},
Usage: "manage blacklist",
Commands: []*cli.Command{
{
Name: "add",
Usage: "add to blacklist",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.AddBlacklist(command.Args().Get(0))
},
},
{
Name: "remove",
Usage: "remove from blacklist",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.RemoveBlacklist(command.Args().Get(0))
},
},
{
Name: "show",
Usage: "show blacklist",
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.ListBlacklist()
},
},
},
},
},
Action: func(ctx context.Context, command *cli.Command) error {
return cmd.Main(command.Args().Get(0))
},
}
if err := command.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}