-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
44 lines (37 loc) · 933 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"
"github.com/corvus-ch/bilocation/cmd"
stdLog "log"
"os"
"github.com/bketelsen/logr"
"github.com/corvus-ch/logr/std"
"github.com/corvus-ch/logr/writer_adapter"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func App(log logr.Logger) *kingpin.Application {
w := writer_adapter.NewBufferedErrorWriter(log)
app := kingpin.New("bilocation", "file management with tags")
app.ErrorWriter(w)
app.UsageWriter(w)
app.Version(fmt.Sprintf("%v, commit %v, built at %v", version, commit, date))
cfg := cmd.NewConfig(log)
cmd.Tag(app, cfg)
cmd.Untag(app, cfg)
cmd.Inspect(app, cfg)
cmd.Search(app, cfg)
cmd.Summary(app, cfg)
return app
}
func main() {
log := std.New(0, stdLog.New(os.Stderr, "", 0), stdLog.New(os.Stdout, "", 0))
if _, err := App(log).Parse(os.Args[1:]); err != nil {
log.Errorf("%s, try --help", err)
os.Exit(1)
}
}