-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathargs.go
41 lines (33 loc) · 775 Bytes
/
args.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
package main
import (
_ "fmt"
"strings"
"github.com/alecthomas/kong"
)
type CLIContext struct {
Verbose int `help:"Run in verbose mode." short:"v" type:"counter"`
}
var CLI struct {
CLIContext
Create Create `cmd help:"Create a new papersave archive."`
Decode Decode `cmd help:"Decode QRcodes images files."`
Check Check `cmd help:"Check base64 file."`
Combine Combine `cmd help:"Combine multiple parts."`
}
func parseCli() {
var methods []string
for k, _ := range QRCodeDecoders {
methods = append(methods, k)
}
ctx := kong.Parse(&CLI,
kong.Vars{
"qrcode_methods": strings.Join(methods[:], ","),
},
kong.UsageOnError(),
)
err := ctx.Run(&CLIContext{
Verbose: CLI.Verbose,
})
// fmt.Printf("%#v\n", CLI)
ctx.FatalIfErrorf(err)
}