-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (56 loc) · 1.36 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
package main
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"github.com/urfave/cli/v2"
"lopper/ui"
"os"
)
func main() {
app := &cli.App{
Name: "lopper",
Usage: "removes dead local Git branches",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Aliases: []string{"p"},
Usage: "path to the repository or root directory containing Git repositories",
Required: true,
},
&cli.StringSliceFlag{
Name: "protected-branch",
Aliases: []string{"b"},
Usage: "branches that are protected from deletion (e.g. -b foo -b bar -b baz)",
},
&cli.IntFlag{
Name: "concurrency",
Aliases: []string{"c"},
Usage: "determines how many repositories to process concurrently",
Value: 1,
},
&cli.BoolFlag{
Name: "dry-run",
Usage: "runs thru the process without actually removing branches",
},
},
Action: func(ctx *cli.Context) error {
m := ui.NewModel(
ui.Path(ctx.String("path")),
ui.ProtectedBranches(ctx.StringSlice("protected-branch")),
ui.Concurrency(ctx.Int("concurrency")),
ui.DryRun(ctx.Bool("dry-run")),
)
if err := tea.NewProgram(m, tea.WithAltScreen()).Start(); err != nil {
return err
}
if m.Error() != nil {
return m.Error()
}
return nil
},
}
// start lopping some branches
if err := app.Run(os.Args); err != nil {
fmt.Println(err)
}
}