✨ Allow value prefixed with bang to skip parsing
This commit is contained in:
parent
d0b6c40445
commit
a8cbfd087f
2 changed files with 8 additions and 0 deletions
|
|
@ -17,6 +17,10 @@ func ParseString(in string) any {
|
|||
return s
|
||||
}
|
||||
|
||||
if strings.HasPrefix(s, "!") {
|
||||
return strings.TrimPrefix(s, "!")
|
||||
}
|
||||
|
||||
yesno := regexp.MustCompile("^(y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)$")
|
||||
yes := regexp.MustCompile("^(y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON)$")
|
||||
null := regexp.MustCompile("^(~|null|Null|NULL|none|None|NONE|nil|Nil|NIL)$")
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ func TestParse(t *testing.T) {
|
|||
{"on-value", "on", true},
|
||||
{"no-value", "no", false},
|
||||
{"off-value", "off", false},
|
||||
{"skip-parsing-num", "!42", "42"},
|
||||
{"skip-parsing-bool", "!false", "false"},
|
||||
{"skip-parsing-time", "!" + when.Format(time.RFC3339), when.Format(time.RFC3339)},
|
||||
{"skip-parsing-duration", "!15 mins", "15 mins"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue