-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
72 lines (66 loc) · 1.66 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
package main
import (
"fmt"
"log"
"os"
"github.com/hoglandets-it/go-bankgiro/shell"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "go-bankgiro",
HelpName: "go-bankgiro",
Description: "A tool to seal and validate Bankgiro files with HMAC",
Commands: []*cli.Command{
{
Name: "seal",
Aliases: []string{"s"},
Usage: "seal a file with a given key",
Args: true,
ArgsUsage: " [file-to-sign]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "key",
Aliases: []string{"k"},
Required: true,
Usage: "key to seal the file with",
EnvVars: []string{"BG_SEAL_KEY"},
},
&cli.StringFlag{
Name: "kvv",
Aliases: []string{"v"},
Required: false,
Usage: "kvv to check the seal with (optional)",
EnvVars: []string{"BG_SEAL_KVV"},
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Required: false,
Usage: "output file, default is [file-to-sign]-signed",
EnvVars: []string{"BG_SEAL_OUTPUT"},
},
&cli.StringFlag{
Name: "overwrite",
Aliases: []string{"f"},
Required: false,
DefaultText: "false",
Usage: "overwrite the output file if it exists",
EnvVars: []string{"BG_SEAL_OVERWRITE"},
},
},
Action: func(c *cli.Context) error {
err := shell.ParseVars(c)
if err != nil {
return err
}
fmt.Printf("Parameters, valid, starting seal on file %s \r\n", c.Args().First())
return shell.SealFile(c)
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}