Current section

Files

Jump to
clip src clip@help.erl
Raw

src/clip@help.erl

-module(clip@help).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/clip/help.gleam").
-export([run/2, custom/1, simple/2]).
-export_type([help/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Functions for building `Help` flags.\n").
-opaque help() :: {help, fun((clip@arg_info:arg_info()) -> binary())}.
-file("src/clip/help.gleam", 10).
?DOC(false).
-spec run(help(), clip@arg_info:arg_info()) -> binary().
run(Help, Arg_info) ->
(erlang:element(2, Help))(Arg_info).
-file("src/clip/help.gleam", 16).
?DOC(
" Generate custom help text by providing a function that transforms\n"
" `ArgInfo` into a `String`.\n"
).
-spec custom(fun((clip@arg_info:arg_info()) -> binary())) -> help().
custom(F) ->
{help, F}.
-file("src/clip/help.gleam", 21).
?DOC(" Generate help text from a name and description.\n").
-spec simple(binary(), binary()) -> help().
simple(Name, Description) ->
{help,
fun(_capture) ->
clip@arg_info:help_text(_capture, Name, Description)
end}.