From 4b93497c2d45851b828225f991512be06892c0b5 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Tue, 28 Dec 2021 13:47:09 -0600 Subject: [PATCH] move validate to dependency validate --- README.md | 2 +- cmd/bindown/cli.go | 8 ++++---- cmd/bindown/dependency.go | 14 ++++++++++++++ docs/clihelp.txt | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 54f72f82..241c4282 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Commands: dependency info info about a dependency dependency show-config show dependency config dependency update-vars update dependency vars + dependency validate validate that installs work template list list templates template remove remove a template template update-from-source update a template from source @@ -188,7 +189,6 @@ Commands: supported-system remove remove a supported system checksums add add checksums to the config file checksums prune remove unnecessary checksums from the config file - validate validate that installs work init create an empty config file version show bindown version install-completions install shell completions diff --git a/cmd/bindown/cli.go b/cmd/bindown/cli.go index 5ba6c5f1..4beb2fdd 100644 --- a/cmd/bindown/cli.go +++ b/cmd/bindown/cli.go @@ -24,7 +24,6 @@ var kongVars = kong.Vars{ "add_checksums_help": `add checksums to the config file`, "prune_checksums_help": `remove unnecessary checksums from the config file`, "config_format_help": `formats the config file`, - "config_validate_bin_help": `name of the binary to validate`, "config_validate_help": `validate that installs work`, "config_install_completions_help": `install shell completions`, "config_extract_path_help": `output path to directory where the downloaded archive is extracted`, @@ -55,12 +54,13 @@ var cli struct { TemplateSource templateSourceCmd `kong:"cmd,help='manage template sources'"` SupportedSystem supportedSystemCmd `kong:"cmd,help='manage supported systems'"` Checksums checksumsCmd `kong:"cmd,help='manage checksums'"` - AddChecksums addChecksumsCmd `kong:"cmd,hidden"` - Validate validateCmd `kong:"cmd,help=${config_validate_help}"` Init initCmd `kong:"cmd,help='create an empty config file'"` Version versionCmd `kong:"cmd,help='show bindown version'"` InstallCompletions kongplete.InstallCompletions `kong:"cmd,help=${config_install_completions_help}"` + + AddChecksums addChecksumsCmd `kong:"cmd,hidden"` + Validate validateCmd `kong:"cmd,hidden"` } type defaultConfigLoader struct{} @@ -154,7 +154,7 @@ func (c fmtCmd) Run(_ *kong.Context) error { } type validateCmd struct { - Dependency string `kong:"required=true,arg,help=${config_validate_bin_help},predictor=bin"` + Dependency string `kong:"required=true,arg,predictor=bin"` Systems []bindown.SystemInfo `kong:"name=system,predictor=allSystems"` } diff --git a/cmd/bindown/dependency.go b/cmd/bindown/dependency.go index 659419c7..4c5ac99b 100644 --- a/cmd/bindown/dependency.go +++ b/cmd/bindown/dependency.go @@ -18,6 +18,7 @@ type dependencyCmd struct { Info dependencyInfoCmd `kong:"cmd,help='info about a dependency'"` ShowConfig dependencyShowConfigCmd `kong:"cmd,help='show dependency config'"` UpdateVars dependencyUpdateVarCmd `kong:"cmd,help='update dependency vars'"` + Validate dependencyValidateCmd `kong:"cmd,help='validate that installs work'"` } type dependencyUpdateVarCmd struct { @@ -221,3 +222,16 @@ func (c *dependencyAddCmd) promptRequiredVars(ctx *kong.Context, config ifaces.C } return nil } + +type dependencyValidateCmd struct { + Dependency string `kong:"arg,predictor=bin"` + Systems []bindown.SystemInfo `kong:"name=system,predictor=allSystems"` +} + +func (d dependencyValidateCmd) Run(ctx *kong.Context) error { + config, err := configLoader.Load(cli.Configfile, false) + if err != nil { + return err + } + return config.Validate([]string{d.Dependency}, d.Systems) +} diff --git a/docs/clihelp.txt b/docs/clihelp.txt index fe20d516..f80c77ae 100644 --- a/docs/clihelp.txt +++ b/docs/clihelp.txt @@ -19,6 +19,7 @@ Commands: dependency info info about a dependency dependency show-config show dependency config dependency update-vars update dependency vars + dependency validate validate that installs work template list list templates template remove remove a template template update-from-source update a template from source @@ -31,7 +32,6 @@ Commands: supported-system remove remove a supported system checksums add add checksums to the config file checksums prune remove unnecessary checksums from the config file - validate validate that installs work init create an empty config file version show bindown version install-completions install shell completions