From cf8049564cf0617edb88d16e791db60359c6819f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Sat, 8 Jul 2023 18:18:11 +0200 Subject: [PATCH] Add SetToDefault bool for presenting whether a flag is set to the default or not MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın --- model.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/model.go b/model.go index 793cf97..47a83cf 100644 --- a/model.go +++ b/model.go @@ -246,6 +246,7 @@ type Value struct { Position int // Position (for positional arguments). Passthrough bool // Set to true to stop flag parsing when encountered. Active bool // Denotes the value is part of an active branch in the CLI. + SetToDefault bool // Set to true when this value is set to default value. } // EnumMap returns a map of the enums in this value. @@ -380,6 +381,9 @@ func (v *Value) Reset() error { } } if v.HasDefault { + if !v.Set { + v.SetToDefault = true + } return v.Parse(ScanFromTokens(Token{Type: FlagValueToken, Value: v.Default}), v.Target) } return nil