Current section

Files

Jump to
oaspec src oaspec.erl
Raw

src/oaspec.erl

-module(oaspec).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/oaspec.gleam").
-export([main/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.
-file("src/oaspec.gleam", 22).
-spec run_glint(list(binary())) -> nil.
run_glint(Arguments) ->
case glint:execute(oaspec@cli:app(), Arguments) of
{error, Message} ->
gleam_stdlib:println_error(Message),
erlang:halt(1);
{ok, {help, Text}} ->
gleam_stdlib:println(Text);
{ok, {out, _}} ->
nil
end.
-file("src/oaspec.gleam", 14).
?DOC(
" CLI entry point for the oaspec code generator.\n"
"\n"
" Routes diagnostic output to stderr while keeping requested output (such as\n"
" `--help` text) on stdout, following POSIX/CLIG conventions.\n"
).
-spec main() -> nil.
main() ->
Arguments = erlang:element(4, argv:load()),
case Arguments of
[<<"--version"/utf8>> | _] ->
gleam_stdlib:println(
<<"oaspec v"/utf8, (<<"0.18.0"/utf8>>)/binary>>
);
_ ->
run_glint(Arguments)
end.