aboutsummaryrefslogtreecommitdiff
path: root/builtins/bool.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-11 14:53:48 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-11 14:53:48 -0400
commitdb0d5a1c204fb48afa5e5a53cb3c703590645f8f (patch)
treee559f108bb3c198faa3863a32cbfe3402a3f4563 /builtins/bool.c
parent0b5bb32912cfc68c7783548006fca2dc5874eb93 (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.c8
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;
}
}