Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5cbb658

Browse files
committedFeb 21, 2024
Add opt.SetValue
1 parent 2b8f132 commit 5cbb658

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎user_options.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ func (gopt *GetOpt) Value(name string) interface{} {
185185
return nil
186186
}
187187

188+
func (gopt *GetOpt) SetValue(name string, value ...string) error {
189+
if v, ok := gopt.programTree.ChildOptions[name]; ok {
190+
return v.Save(value...)
191+
}
192+
panic("option not found")
193+
}
194+
188195
// Bool - define a `bool` option and its aliases.
189196
// It returns a `*bool` pointing to the variable holding the result.
190197
// If the option is found, the result will be the opposite of the provided default.

0 commit comments

Comments
 (0)
Please sign in to comment.