Current section

Files

Jump to
outil src outil@core.erl
Raw

src/outil@core.erl

-module(outil@core).
-compile(no_auto_import).
-export([parse_bool/1]).
-export_type([command/1, argument/0, opt/0, opt_value/0, error/0]).
-type command(ESL) :: {command,
binary(),
binary(),
list(argument()),
list(opt()),
fun((list(binary())) -> {ok, ESL} | {error, error()})}.
-type argument() :: {bool_argument, binary()} |
{float_argument, binary()} |
{int_argument, binary()} |
{string_argument, binary()}.
-type opt() :: {opt,
binary(),
gleam@option:option(binary()),
binary(),
opt_value()}.
-type opt_value() :: bool_opt |
{float_opt, float()} |
{int_opt, integer()} |
{string_opt, binary()}.
-type error() :: {malformed_argument, binary(), binary()} |
{missing_argument, binary()} |
{not_implemented, binary()} |
{out_of_place_option, binary()}.
-spec parse_bool(binary()) -> {ok, boolean()} | {error, nil}.
parse_bool(Arg) ->
case Arg of
<<"true"/utf8>> ->
{ok, true};
<<"false"/utf8>> ->
{ok, false};
_ ->
{error, nil}
end.