Packages
A Gleam library for writing command line tools.
Current section
Files
Jump to
Current section
Files
src/outil.erl
-module(outil).
-compile(no_auto_import).
-export([command/4, parse_bool/1]).
-export_type([command/0, argument/0, opt/0, opt_value/0, return/0]).
-type command() :: {command,
binary(),
binary(),
list(argument()),
list(opt()),
list(binary())}.
-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 return() :: {command_line_error, outil@error:reason(), binary()} |
{help, binary()}.
-spec command(binary(), binary(), list(binary()), fun((command()) -> EST)) -> EST.
command(Name, Description, Argv, Continue) ->
Continue({command, Name, Description, [], [], Argv}).
-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.