-module(gladvent). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/gladvent.gleam"). -export([run/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/gladvent.gleam", 47). -spec print_snag_and_halt(snag:snag()) -> nil. print_snag_and_halt(Err) -> _pipe = Err, _pipe@1 = snag:pretty_print(_pipe), gleam_stdlib:println(_pipe@1), erlang:halt(1). -file("src/gladvent.gleam", 14). ?DOC( " Add this function to your project's `main` function in order to run the gladvent CLI.\n" "\n" " This function gets its input from the command line arguments by using the `argv` library.\n" ). -spec run() -> nil. run() -> Commands = begin _pipe = glint:new(), _pipe@1 = glint:path_help( _pipe, [], <<"gladvent is an advent of code runner and generator for gleam. Please use either the 'run' or 'new' commands. "/utf8>> ), _pipe@2 = glint:pretty_help(_pipe@1, glint:default_pretty_help()), _pipe@3 = glint:group_flag( _pipe@2, [], gladvent@internal@cmd:year_flag() ), _pipe@4 = glint:add( _pipe@3, [<<"new"/utf8>>], gladvent@internal@cmd@new:new_command() ), _pipe@5 = glint:group_flag( _pipe@4, [<<"run"/utf8>>], gladvent@internal@cmd@run:timeout_flag() ), _pipe@6 = glint:group_flag( _pipe@5, [<<"run"/utf8>>], gladvent@internal@cmd@run:allow_crash_flag() ), _pipe@7 = glint:group_flag( _pipe@6, [<<"run"/utf8>>], gladvent@internal@cmd@run:timed_flag() ), _pipe@8 = glint:add( _pipe@7, [<<"run"/utf8>>], gladvent@internal@cmd@run:run_command() ), glint:add( _pipe@8, [<<"run"/utf8>>, <<"all"/utf8>>], gladvent@internal@cmd@run:run_all_command() ) end, glint:run_and_handle( Commands, erlang:element(4, argv:load()), fun(Out) -> case Out of {ok, Out@1} -> _pipe@9 = Out@1, _pipe@10 = gleam@string:join(_pipe@9, <<"\n\n"/utf8>>), gleam_stdlib:println(_pipe@10); {error, Err} -> print_snag_and_halt(Err) end end ).