Skip to content

Commit

Permalink
add kongplete
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Feb 18, 2020
1 parent 76780bd commit 03b3a20
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
19 changes: 11 additions & 8 deletions cmd/bindown/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ import (

"github.com/alecthomas/kong"
"github.com/willabides/bindown/v2"
"github.com/willabides/kongplete"
)

var configKongVars = kong.Vars{
"config_format_help": `formats the config file`,
"config_checksums_help": `update checksums in the config file`,
"config_checksums_bin_help": `name of the binary to update`,
"config_validate_bin_help": `name of the binary to validate`,
"config_validate_help": `validate that downloads work`,
"config_format_help": `formats the config file`,
"config_checksums_help": `update checksums in the config file`,
"config_checksums_bin_help": `name of the binary to update`,
"config_validate_bin_help": `name of the binary to validate`,
"config_validate_help": `validate that downloads work`,
"config_install_completions_help": `install shell completions`,
}

type configCmd struct {
Format configFmtCmd `kong:"cmd,help=${config_format_help}"`
UpdateChecksums configUpdateChecksumsCmd `kong:"cmd,help=${config_checksums_bin_help}"`
Validate configValidateCmd `kong:"cmd,help=${config_validate_help}"`
Format configFmtCmd `kong:"cmd,help=${config_format_help}"`
UpdateChecksums configUpdateChecksumsCmd `kong:"cmd,help=${config_checksums_bin_help}"`
Validate configValidateCmd `kong:"cmd,help=${config_validate_help}"`
InstallCompletions kongplete.InstallCompletions `kong:"cmd,help="`
}

type configFmtCmd struct{}
Expand Down
3 changes: 3 additions & 0 deletions cmd/bindown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/alecthomas/kong"
"github.com/willabides/kongplete"
)

var kongVars = kong.Vars{
Expand Down Expand Up @@ -59,6 +60,8 @@ func main() {
kong.NamedMapper("multipath", kong.MapperFunc(multipathMapper)),
)

kongplete.Complete(parser)

kongCtx, err := parser.Parse(os.Args[1:])
parser.FatalIfErrorf(err)
kongCtx.FatalIfErrorf(kongCtx.Run(kongCtx))
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ module github.com/willabides/bindown/v2
go 1.12

require (
github.com/alecthomas/kong v0.2.1
github.com/alecthomas/kong v0.2.2
github.com/andybalholm/brotli v1.0.0 // indirect
github.com/frankban/quicktest v1.4.2 // indirect
github.com/mholt/archiver/v3 v3.3.0
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pierrec/lz4 v2.3.0+incompatible // indirect
github.com/stretchr/testify v1.4.0
github.com/udhos/equalfile v0.3.0
github.com/willabides/kongplete v0.0.0-20200218163413-c50671632cd8
gopkg.in/yaml.v2 v2.2.2
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/alecthomas/kong v0.2.1 h1:V1tLBhyQBC4rsbXbcOvm3GBaytJSwRNX69fp1WJxbqQ=
github.com/alecthomas/kong v0.2.1/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
github.com/alecthomas/kong v0.2.2 h1:sk9ucwuUP/T4+byYEdNU13ZNYzoQRML4IsrMbbUUKLk=
github.com/alecthomas/kong v0.2.2/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U=
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
Expand All @@ -16,6 +18,10 @@ github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.9.2 h1:LfVyl+ZlLlLDeQ/d2AqfGIIH4qEDu0Ed2S5GyhCWIWY=
github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
Expand All @@ -39,6 +45,8 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
Expand All @@ -47,6 +55,8 @@ github.com/udhos/equalfile v0.3.0 h1:KhG4xhhkittrgIV/ekHtpEPh7MLxtbjm6kLEwp5Dlbg
github.com/udhos/equalfile v0.3.0/go.mod h1:1LOX9HjdFMke7ryP3IPby09FkswyY5KzhhsT37wLz/Y=
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/willabides/kongplete v0.0.0-20200218163413-c50671632cd8 h1:fozkUJwUVv1Wt2/+wOqoVjnttFMu5pH1mArJ7Ueqssc=
github.com/willabides/kongplete v0.0.0-20200218163413-c50671632cd8/go.mod h1:kFVw+PkQsqkV7O4tfIBo6iJ9qY94PJC8sPfMgFG5AdM=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down

0 comments on commit 03b3a20

Please sign in to comment.