2023-11-12 17:19:34 -05:00
|
|
|
package opt
|
2023-11-11 19:28:58 -05:00
|
|
|
|
|
|
|
type StringOption struct {
|
|
|
|
name string
|
|
|
|
shortName string
|
|
|
|
description string
|
|
|
|
value string
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Option = (*StringOption)(nil)
|
|
|
|
|
|
|
|
func String(name, shortName, defaultValue, description string) *StringOption {
|
|
|
|
return &StringOption{
|
|
|
|
name: name,
|
|
|
|
shortName: shortName,
|
|
|
|
description: description,
|
|
|
|
value: defaultValue,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Description implements Option.
|
|
|
|
func (o *StringOption) Description() string {
|
|
|
|
return o.description
|
|
|
|
}
|
|
|
|
|
|
|
|
// Name implements Option.
|
|
|
|
func (o *StringOption) Name() string {
|
|
|
|
return o.name
|
|
|
|
}
|
|
|
|
|
|
|
|
// ShortName implements Option.
|
|
|
|
func (o *StringOption) ShortName() string {
|
|
|
|
return o.shortName
|
|
|
|
}
|
|
|
|
|
|
|
|
// Value implements Option.
|
|
|
|
func (o *StringOption) Parse(raw string) error {
|
|
|
|
if raw == "" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
o.value = raw
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-11-12 17:07:38 -05:00
|
|
|
// RequiresVal implements Option.
|
|
|
|
func (*StringOption) RequiresVal() bool {
|
2023-11-11 20:49:38 -05:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2023-11-11 19:28:58 -05:00
|
|
|
func (o *StringOption) Value() string {
|
|
|
|
return o.value
|
|
|
|
}
|