Skip to content
Snippets Groups Projects
Verified Commit 2728224f authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: hint and error functions

parent 2b16160e
No related branches found
No related tags found
No related merge requests found
...@@ -20,19 +20,16 @@ func (s *Settings[C]) HasErrors() bool { ...@@ -20,19 +20,16 @@ func (s *Settings[C]) HasErrors() bool {
return len(s.errors) > 0 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 // Get all errors
func (s *Settings[C]) Errors() []error { func (s *Settings[C]) Errors() []error {
return s.errors 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 WatchListNotInitializedError = errors.New("watch list not initialized")
var MissingCommandError = errors.New("missing command") var MissingCommandError = errors.New("missing command")
var NotParsedError = errors.New("flag set not parsed") var NotParsedError = errors.New("flag set not parsed")
......
...@@ -96,7 +96,7 @@ func getFlagTable(f *flag.FlagSet) []string { ...@@ -96,7 +96,7 @@ func getFlagTable(f *flag.FlagSet) []string {
// isZeroValue determines whether the string represents the zero // isZeroValue determines whether the string represents the zero
// value for a flag. // value for a flag.
func isZeroValue(f *flag.Flag, value string) (ok bool, err error) { 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. // result of calling its String method equals the value passed in.
// This works unless the Value type is itself an interface type. // This works unless the Value type is itself an interface type.
typ := reflect.TypeOf(f.Value) typ := reflect.TypeOf(f.Value)
......
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
}
...@@ -37,7 +37,7 @@ func (s *Settings[C]) assignValues(c cmd[C]) { ...@@ -37,7 +37,7 @@ func (s *Settings[C]) assignValues(c cmd[C]) {
flgs.Visit(func(f *flag.Flag) { flgs.Visit(func(f *flag.Flag) {
name := f.Name name := f.Name
value := f.Value.String() value := f.Value //.String()
k, ok := c.tagMapping[name] k, ok := c.tagMapping[name]
if !ok { if !ok {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment