-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
66 lines (52 loc) · 1.41 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
package main
import (
"fmt"
"os"
docopt "github.com/docopt/docopt-go"
hierr "github.com/reconquest/hierr-go"
)
var (
version = "[manual build]"
err error
OutputFileMode os.FileMode = 0644
Help = `Authorize trello.com.
Open https://trello.com/app-key and take Key.
Next click generate a Token and take him.`
)
func main() {
usage := `trello-cli
Usage:
trello-cli [options] <name> [<description>]
trello-cli [options] -S
Options:
-c --config <path> Use specified configuration file
[default: $HOME/.config/trello.conf].
Commands:
-S Setup AppKey, token, board, list.
Add card options:
<name> Card name.
<description> Card description (optionals).
Misc options:
--version Show version.
-h --help Show this screen.
`
args, err := docopt.Parse(usage, nil, true, version, false)
if err != nil {
panic(hierr.Errorf(err, "can't parse docopt"))
}
path := os.ExpandEnv(args["--config"].(string))
config, err := loadConfig(path)
if err != nil {
hierr.Fatalf(err, "problem with configuration, run setup")
}
switch {
case args["-S"].(bool):
fmt.Println(Help)
err = handleSetup(path, config)
default:
err = handleAdd(config, args)
}
if err != nil {
hierr.Errorf(err, "an error occurred during the process")
}
}