-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (50 loc) · 1.04 KB
/
main.go
File metadata and controls
60 lines (50 loc) · 1.04 KB
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
package main
import (
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
"github.com/Marvin9/licensor/utils"
"github.com/Marvin9/licensor/steps"
)
func main() {
closeSignal()
if runtime.GOOS == "windows" {
utils.IsWindows = true
}
if !utils.IsWindows {
fmt.Print("\033[s") // save cursor position
fmt.Print("\033[?25l") // hide cursor
}
// find . | grep -i "\(\.go\|\.sh\)$" | wc -l
var model steps.CommandModel
model.MakeModel(os.Args)
model.Validate()
if !model.RemoveFlag {
lc := model.LoadLicense()
lc = model.InjectVariable(lc)
lc = model.Pretty(lc)
model.LicenseText = lc
}
if utils.IsWindows {
fmt.Print("Working...")
}
model.Start()
// https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#completeness
if !utils.IsWindows {
fmt.Print("\u001b[2K")
fmt.Print("\u001b[0G")
}
fmt.Println("Done ✔️")
utils.ShowCursor()
}
func closeSignal() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
utils.ShowCursor()
os.Exit(1)
}()
}