MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / OnAnswerWithReset

Method OnAnswerWithReset

internal/plugins/plugin.go:245–271  ·  view source on GitHub ↗
(answer string, isReset bool)

Source from the content-addressed store, hash-verified

243}
244
245func (o *SetupQuestion) OnAnswerWithReset(answer string, isReset bool) (err error) {
246 if o.Type == SettingTypeBool {
247 if answer == "" {
248 o.Value = ""
249 } else {
250 _, err := ParseBool(answer)
251 if err != nil {
252 return fmt.Errorf(i18n.T("plugin_invalid_boolean_value"), answer)
253 }
254 o.Value = strings.ToLower(answer)
255 }
256 } else {
257 o.Value = answer
258 }
259 if o.EnvVariable != "" {
260 if err = os.Setenv(o.EnvVariable, o.Value); err != nil {
261 return
262 }
263 }
264 // Skip validation when explicitly resetting a value - the user intentionally
265 // wants to clear the value even if it's required
266 if isReset {
267 return nil
268 }
269 err = o.IsValidErr()
270 return
271}
272
273func (o *Setting) IsValidErr() (err error) {
274 if !o.IsValid() {

Callers 3

AskMethod · 0.95
OnAnswerMethod · 0.95

Calls 3

TFunction · 0.92
ParseBoolFunction · 0.85
IsValidErrMethod · 0.80

Tested by 1