-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (39 loc) · 860 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
46
47
48
49
50
package main
import (
"fmt"
"time"
"github.com/spf13/cobra"
"github.com/wayneashleyberry/lut/cmd/apply"
"github.com/wayneashleyberry/lut/cmd/convert"
"github.com/wayneashleyberry/lut/pkg/util"
)
var version string
var date string
func main() {
root := &cobra.Command{
Use: "lut",
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Usage()
},
}
root.AddCommand(
apply.Command(),
convert.Command(),
)
root.AddCommand(&cobra.Command{
Use: "version",
Short: "Print version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("lut v%s (%s)\n", version, date)
},
})
var verbose bool
root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
t := time.Now()
if err := root.Execute(); err != nil {
util.Exit(err)
}
if verbose {
fmt.Println(time.Since(t))
}
}