-
Notifications
You must be signed in to change notification settings - Fork 24
/
main.go
53 lines (43 loc) · 1.01 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
package main
import (
"fmt"
"log"
"os"
"github.com/andreazorzetto/yh/highlight"
)
const version = "0.4.0"
func main() {
log.SetFlags(0) // disable timestamp of log package
// Checking the args, someone out there might need help
checkArgs(os.Args)
h, err := highlight.Highlight(os.Stdin)
if err != nil {
log.Fatalln(err)
}
fmt.Print(h)
}
// Check args if passed
// Show help
func checkArgs(a []string) {
if len(a) >= 2 {
// Someone's looking for...
if a[1] == "version" {
// version
fmt.Println(version)
os.Exit(0)
} else if a[1] == "help" {
// help
fmt.Println("You don't really need to read this! \nJust pipe me some YAML. I don't bite")
fmt.Println("\nExample:")
fmt.Println("\tkubectl get myNastyPod -o yaml | yh")
fmt.Println("\nCommands:")
fmt.Println("\thelp: get this helpful help")
fmt.Println("\tversion: get the version")
os.Exit(0)
} else {
// trolling
fmt.Println("Not really sure of what you want! Maybe try help or version.")
os.Exit(0)
}
}
}