-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (39 loc) · 797 Bytes
/
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
package main
import (
"fmt"
"log"
"os"
"github.com/charmbracelet/lipgloss"
"github.com/urfave/cli/v2"
"github.com/wesleimp/fswatch/internal/runner"
)
var errStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9"))
func main() {
pwd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
app := &cli.App{
Name: "fswatch",
Usage: "Run commands when file changes",
Version: "0.1.0",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Usage: "path to watch",
Value: pwd,
},
},
Action: func(c *cli.Context) error {
conf := runner.Config{
Command: c.Args().Slice(),
Path: c.String("path"),
}
return runner.Run(conf)
},
}
if err := app.Run(os.Args); err != nil {
fmt.Println(errStyle.Render(err.Error()))
os.Exit(1)
}
}