-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (36 loc) · 1022 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
package main
import (
"fmt"
"os"
"runtime"
"github.com/fatih/color"
"github.com/jessevdk/go-flags"
"github.com/ztrue/tracerr"
)
const version = "1.1.0"
var opts struct {
Verbose bool `short:"v" long:"verbose" description:"Print verbose output"`
Version bool `long:"version" description:"Print version and exit"`
Color bool `short:"c" long:"color" description:"Color output"`
Username string `short:"u" long:"username" description:"Username of duinocoin user"`
}
func main() {
if _, err := flags.NewParser(&opts, flags.HelpFlag|flags.PassDoubleDash).Parse(); err != nil {
tracerr.Print(err)
os.Exit(1)
}
if opts.Version {
if opts.Color {
fmt.Fprintln(color.Output, y("ducolookup"), w("version"), version)
fmt.Fprintln(color.Output, c("Go"), w("version"), runtime.Version())
} else {
fmt.Println("ducolookup version", version)
fmt.Println("Go version", runtime.Version())
}
os.Exit(0)
}
if err := printUserInfo(); err != nil {
tracerr.Print(err)
os.Exit(1)
}
}