From 073cc6df64c927a7a40fc5a3182ddf7c5015b8ca Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 26 Mar 2017 04:50:21 +0200 Subject: [PATCH] add get maybe bool from web argument --- web/CXM_web_arg_utils.anubis | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/web/CXM_web_arg_utils.anubis b/web/CXM_web_arg_utils.anubis index 4b0a285..832b813 100644 --- a/web/CXM_web_arg_utils.anubis +++ b/web/CXM_web_arg_utils.anubis @@ -129,6 +129,18 @@ public define Maybe(String) } . +public define Maybe(Bool) + get_mb_Bool + ( + List(Web_arg) lwa, + String arg_name + ) = + if web_arg_value(lwa, arg_name) is + { + not_found then failure, + found(value) then success(to_Bool(value)) + }. + public define Bool get_Bool ( @@ -137,8 +149,8 @@ public define Bool ) = if web_arg_value(lwa, arg_name) is { - not_found then false, - found(_) then true + not_found then false, + found(value) then true }. public define Bool -- libgit2 0.21.4