-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
48 lines (40 loc) · 904 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
46
47
48
package main
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/toudi/jpk_vat_7/commands"
)
var err error
var availableCommands = []commands.Command{
commands.GenerateCmd.Command,
commands.MetadataCmd.Command,
commands.UploadCmd.Command,
commands.StatusCmd.Command,
commands.UpoCommand.Command,
}
func usage() {
fmt.Printf("Proszę użyć jednej z subkomend:\n\n")
for _, cmd := range availableCommands {
fmt.Printf("%-10s %s\n", cmd.FlagSet.Name(), cmd.Description)
}
fmt.Printf("\n")
os.Exit(1)
}
func main() {
log.Info("jpk_vat:: start programu")
if len(os.Args) < 2 {
usage()
}
for _, cmd := range availableCommands {
if os.Args[1] == cmd.FlagSet.Name() {
cmd.FlagSet.Parse(os.Args[2:])
if err = cmd.Run(&cmd); err != nil {
log.Errorf("Błąd wykonywania komendy %s: %v\n", os.Args[1], err)
os.Exit(-1)
}
os.Exit(0)
}
}
usage()
}