Skip to content

Commit

Permalink
Merge pull request #106 from WillAbides/validate
Browse files Browse the repository at this point in the history
move validate to dependency validate
  • Loading branch information
WillAbides authored Dec 28, 2021
2 parents cd585bf + 4b93497 commit 1daabc8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cmd/bindown/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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"`
}

Expand Down
14 changes: 14 additions & 0 deletions cmd/bindown/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion docs/clihelp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1daabc8

Please sign in to comment.