config: improve usage error messages
parent
f36c5d8ed1
commit
46550dbf0d
|
|
@ -30,9 +30,13 @@ var configGetCmd = &cobra.Command{
|
|||
Short: "Gets the value of PROPERTY_NAME from the minikube config file",
|
||||
Long: "Returns the value of PROPERTY_NAME from the minikube config file. Can be overwritten at runtime by flags or environmental variables.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) != 1 {
|
||||
if len(args) == 0 {
|
||||
cmd.SilenceErrors = true
|
||||
return errors.New("usage: minikube config get PROPERTY_NAME")
|
||||
return errors.New("not enough arguments.\nusage: minikube config get PROPERTY_NAME")
|
||||
}
|
||||
if len(args) > 1 {
|
||||
cmd.SilenceErrors = true
|
||||
return fmt.Errorf("too many arguments (%d)\nusage: minikube config get PROPERTY_NAME", len(args))
|
||||
}
|
||||
|
||||
cmd.SilenceUsage = true
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
pkgConfig "k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/exit"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
)
|
||||
|
||||
var configSetCmd = &cobra.Command{
|
||||
|
|
@ -29,8 +30,11 @@ var configSetCmd = &cobra.Command{
|
|||
Long: `Sets the PROPERTY_NAME config value to PROPERTY_VALUE
|
||||
These values can be overwritten by flags or environment variables at runtime.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) != 2 {
|
||||
exit.UsageT("usage: minikube config set PROPERTY_NAME PROPERTY_VALUE")
|
||||
if len(args) < 2 {
|
||||
exit.UsageT("not enough arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE", out.V{"ArgCount": len(args)})
|
||||
}
|
||||
if len(args) > 2 {
|
||||
exit.UsageT("toom any arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE", out.V{"ArgCount": len(args)})
|
||||
}
|
||||
err := Set(args[0], args[1])
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue