diff --git a/error.go b/error.go index 91966f4b334e9831a101960e7f4828716e296138..7086f98a322b8ea092e8be4d79e817450db1f030 100644 --- a/error.go +++ b/error.go @@ -20,19 +20,16 @@ func (s *Settings[C]) HasErrors() bool { return len(s.errors) > 0 } -func (s *Settings[C]) HasHint() bool { - return s.hint != "" -} - -func (s *Settings[C]) GetHint() string { - return s.hint -} - // Get all errors func (s *Settings[C]) Errors() []error { return s.errors } +func (s *Settings[C]) AddError(err error) *Settings[C] { + s.errors = append(s.errors, err) + return s +} + var WatchListNotInitializedError = errors.New("watch list not initialized") var MissingCommandError = errors.New("missing command") var NotParsedError = errors.New("flag set not parsed") diff --git a/help-util.go b/help-util.go index 3a153d09d5b2def425cb1d3c12706ca3d092fd14..c3512fd773ca3236257b513c8a6296bc6eb45283 100644 --- a/help-util.go +++ b/help-util.go @@ -96,7 +96,7 @@ func getFlagTable(f *flag.FlagSet) []string { // isZeroValue determines whether the string represents the zero // value for a flag. func isZeroValue(f *flag.Flag, value string) (ok bool, err error) { - // Build a zero value of the flag's Value type, and see if the + // Sync a zero value of the flag's Value type, and see if the // result of calling its String method equals the value passed in. // This works unless the Value type is itself an interface type. typ := reflect.TypeOf(f.Value) diff --git a/hint.go b/hint.go index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3b4f870cc8080085889fa98312b2055c22c99c5c 100644 --- a/hint.go +++ b/hint.go @@ -0,0 +1,14 @@ +package xflags + +func (s *Settings[C]) SetHint(hint string) *Settings[C] { + s.hint = hint + return s +} + +func (s *Settings[C]) HasHint() bool { + return s.hint != "" +} + +func (s *Settings[C]) GetHint() string { + return s.hint +} diff --git a/mapping.go b/mapping.go index 19a0b66771c6c7947fc10bb2dcc5dc980a2fa7bd..296973d2433d024a29db5a656758dbb7fa0a8cd8 100644 --- a/mapping.go +++ b/mapping.go @@ -37,7 +37,7 @@ func (s *Settings[C]) assignValues(c cmd[C]) { flgs.Visit(func(f *flag.Flag) { name := f.Name - value := f.Value.String() + value := f.Value //.String() k, ok := c.tagMapping[name] if !ok {