-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
85 lines (78 loc) · 1.42 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
var (
author string
version string
)
func main() {
initLogging()
app := initCLI()
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func initCLI() *cli.App {
app := &cli.App{
Name: "BitFluxR",
Version: "0.0.1",
Authors: []*cli.Author{
{
Name: "Ian Carr",
Email: "[email protected]",
},
},
Copyright: "(c) 2020 BitFluxR",
Usage: "Tame all the bits",
//Flags
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"vv"},
Usage: "verbose output",
},
&cli.StringFlag{
Name: "config, c",
Aliases: []string{"c"},
Usage: "load config from `FILE`",
},
&cli.StringFlag{
Name: "log",
},
},
//Commands
Commands: []*cli.Command{
{
Name: "add",
//Aliases: []string{"a"},
Usage: "add data source",
Action: func(c *cli.Context) error {
fmt.Println("added source: ", c.Args().First())
return nil
},
},
{
Name: "complete",
//Aliases: []string{"c"},
Usage: "complete a task on the list",
Action: func(c *cli.Context) error {
fmt.Println("completed task: ", c.Args().First())
return nil
},
},
},
}
return app
}
func initLogging() {
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
log.SetOutput(os.Stdout)
log.SetLevel(log.InfoLevel)
}