-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
52 lines (43 loc) · 936 Bytes
/
cli.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
// Copyright 2016, Homin Lee <homin.lee@suapapa.net>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"log"
"os"
"github.com/mitchellh/cli"
)
const defaultTimeFmt = "Mon, 2006-01-02 15:04:05 MST -0700"
func main() {
err := loadDB()
if err != nil {
fmt.Println("failed to load DB", err)
os.Exit(-1)
}
if len(os.Args) == 1 {
printTimes(defaultTimeFmt)
os.Exit(0)
}
c := cli.NewCLI("wdate", "1.0")
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"add": func() (cli.Command, error) {
var cmd addCmd
return cmd, nil
},
"remove": func() (cli.Command, error) {
var cmd removeCmd
return cmd, nil
},
"fmt": func() (cli.Command, error) {
var cmd fmtCmd
return cmd, nil
},
}
exitStatus, err := c.Run()
if err != nil {
log.Println(err)
}
os.Exit(exitStatus)
}