-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.go
More file actions
63 lines (51 loc) · 1.29 KB
/
init.go
File metadata and controls
63 lines (51 loc) · 1.29 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
61
62
63
package main
import (
"flag"
"log"
"os"
"strings"
"unicode"
"golang.org/x/sys/windows"
)
var (
NoInfo bool
NoWarn bool
NoErr bool
NoColor bool
Exit bool
Verbose bool
RegFilePaths []string
)
const (
WithoutColor = "%s\n"
InfoColor = "\033[1;32m%s\033[0m\n"
WarningColor = "\033[1;33m%s\033[0m\n"
ErrorColor = "\033[1;31m%s\033[0m\n"
PanicColor = "\033[1;35m%s\033[0m\n"
)
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
flag.BoolVar(&NoInfo, "noinfo", false, "Without info")
flag.BoolVar(&NoWarn, "nowarn", false, "Without warnung")
flag.BoolVar(&NoErr, "noerr", false, "Without error")
flag.BoolVar(&NoColor, "nocolor", false, "Without color")
flag.BoolVar(&Exit, "exit", false, "Exit after processing")
flag.BoolVar(&Verbose, "verbose", false, "Verbose line")
flag.Parse()
separatorFunc := func(c rune) bool {
return unicode.IsSpace(c) || c == ';' || c == ','
}
args := flag.Args()
if len(args) != 0 {
RegFilePaths = strings.FieldsFunc(args[0], separatorFunc)
}
enableColor()
}
func enableColor() {
var handle = windows.Handle(os.Stdout.Fd())
var mode uint32
if err := windows.GetConsoleMode(handle, &mode); err == nil {
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
windows.SetConsoleMode(handle, mode)
}
}