generated from gleich/go_template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
45 lines (40 loc) · 942 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
package main
import (
"fmt"
"os"
"time"
"github.com/gleich/ctree/pkg/lights"
"github.com/gleich/ctree/pkg/tree"
"github.com/gleich/statuser/v2"
"github.com/inancgumus/screen"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "ctree",
Usage: "🎄 A Christmas tree right from your terminal!\nRepository: https://github.com/gleich/ctree",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-refresh",
Usage: "Just output the tree once normally",
},
},
Action: func(c *cli.Context) error {
base := tree.ApplyColors(tree.MsgBase)
if c.Bool("no-refresh") {
fmt.Println(lights.ApplyColorsToLights(base))
os.Exit(0)
}
for {
screen.Clear()
screen.MoveTopLeft()
fmt.Println(lights.ApplyColorsToLights(base))
time.Sleep(time.Second * 3)
}
},
}
err := app.Run(os.Args)
if err != nil {
statuser.Error("Failed to parse flags and run main command", err, 1)
}
}