diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 14:53:48 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 14:53:48 -0400 |
| commit | db0d5a1c204fb48afa5e5a53cb3c703590645f8f (patch) | |
| tree | e559f108bb3c198faa3863a32cbfe3402a3f4563 /builtins/bool.c | |
| parent | 0b5bb32912cfc68c7783548006fca2dc5874eb93 (diff) | |
Change *:from_text() methods to return optional values and set up CLI
parsing to use that approach
Diffstat (limited to 'builtins/bool.c')
| -rw-r--r-- | builtins/bool.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/builtins/bool.c b/builtins/bool.c index 63eb73f9..ce27ce79 100644 --- a/builtins/bool.c +++ b/builtins/bool.c @@ -9,6 +9,7 @@ #include <sys/param.h> #include "bool.h" +#include "optionals.h" #include "text.h" #include "types.h" #include "util.h" @@ -23,23 +24,20 @@ PUREFUNC public Text_t Bool$as_text(const bool *b, bool colorize, const TypeInfo return *b ? Text("yes") : Text("no"); } -public Bool_t Bool$from_text(Text_t text, bool *success) +PUREFUNC public OptionalBool_t Bool$from_text(Text_t text) { if (Text$equal_ignoring_case(text, Text("yes")) || Text$equal_ignoring_case(text, Text("on")) || Text$equal_ignoring_case(text, Text("true")) || Text$equal_ignoring_case(text, Text("1"))) { - if (success) *success = yes; return yes; } else if (Text$equal_ignoring_case(text, Text("no")) || Text$equal_ignoring_case(text, Text("off")) || Text$equal_ignoring_case(text, Text("false")) || Text$equal_ignoring_case(text, Text("0"))) { - if (success) *success = yes; return no; } else { - if (success) *success = no; - return no; + return NULL_BOOL; } } |
