-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
45 lines (38 loc) · 848 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
package main
import (
"fmt"
"os"
"github.com/briandowns/todo-view/command"
"github.com/mitchellh/cli"
)
const (
todoViewVersion = "0.2"
todoViewName = "todo-view"
)
func main() {
if retval, err := run(); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(retval)
}
}
func run() (int, error) {
c := &cli.CLI{
Name: todoViewName,
Version: todoViewVersion,
Args: os.Args[1:],
HelpFunc: cli.BasicHelpFunc(todoViewName),
Commands: map[string]cli.CommandFactory{
"parse": command.NewParse(),
"show": command.NewShow(),
"export": command.NewExport(),
"web": command.NewWeb(),
"version": command.NewVersion(todoViewVersion),
},
}
retval, err := c.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1, err
}
return retval, nil
}