add hidden option
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
andrey1s
2022-09-18 22:34:16 +03:00
parent ef4d5d126a
commit 662cbdb510
8 changed files with 55 additions and 25 deletions

View File

@@ -15,6 +15,10 @@ func Default(in interface{}) variable.Option {
return variable.Default(value.New(in))
}
func Hidden(in *variable.Variable) {
variable.Hidden(in)
}
func Required(v *variable.Variable) {
variable.Required(v)
}

View File

@@ -40,6 +40,10 @@ func Required(v *Variable) {
v.Flag |= flag.Required
}
func Hidden(v *Variable) {
v.hidden = true
}
func WithParse(create Create, update Append) Option {
return func(v *Variable) {
v.append = func(Param) Append { return update }
@@ -99,6 +103,7 @@ type Variable struct {
Flag flag.Flag
Type ArgType
Default value.Value
hidden bool
Valid []func(value.Value) error
params Params
create func(Param) Create
@@ -115,6 +120,10 @@ func (v Variable) Validate(in value.Value) error {
return nil
}
func (v Variable) IsHidden() bool {
return v.hidden
}
func (v Variable) IsArray() bool {
return v.Flag.IsArray()
}