Check if value is provided

This commit is contained in:
Phani Teja Marupaka
2021-03-23 15:40:35 -07:00
parent 7b38ce4ef2
commit c3beadacd9
2 changed files with 53 additions and 0 deletions

View File

@@ -71,6 +71,11 @@ func (r *SetRunner) preRunE(c *cobra.Command, args []string) error {
return errors.Errorf("value should set either from flag or arg")
}
// make sure that the value is provided either through values flag or as an arg
if !valueFlagSet && len(args) < 3 {
return errors.Errorf("value must be provided either from flag or arg")
}
r.Name = args[1]
if valueFlagSet {
r.Value = r.Values[0]