Skip to content

Commit

Permalink
Add opt.SetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGamba committed Feb 21, 2024
1 parent 2b8f132 commit 5cbb658
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions user_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ func (gopt *GetOpt) Value(name string) interface{} {
return nil
}

func (gopt *GetOpt) SetValue(name string, value ...string) error {
if v, ok := gopt.programTree.ChildOptions[name]; ok {
return v.Save(value...)
}
panic("option not found")
}

// Bool - define a `bool` option and its aliases.
// It returns a `*bool` pointing to the variable holding the result.
// If the option is found, the result will be the opposite of the provided default.
Expand Down

0 comments on commit 5cbb658

Please sign in to comment.