-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (42 loc) · 787 Bytes
/
main.go
File metadata and controls
54 lines (42 loc) · 787 Bytes
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
package main
import (
"fmt"
"log"
"os"
"github.com/andresterba/trello-cli/commands"
)
func checkForError(err error) {
if err != nil {
log.Fatalln(err)
}
}
func showHelp() {
fmt.Println(`
trello-cli [command] [options]
commands:`)
for _, command := range commands.GetRegisteredCommands() {
name, description := command.GetInformation()
fmt.Printf(" %s - %s\n", name, description)
}
}
func main() {
args := os.Args
if len(args) < 2 {
showHelp()
os.Exit(1)
}
params := args[1:]
commandExecuted := false
for _, command := range commands.GetRegisteredCommands() {
if command.IsForCommand(params) {
err := command.Execute(params)
checkForError(err)
commandExecuted = true
break
}
}
if !commandExecuted {
showHelp()
os.Exit(0)
}
}