-module(showtime). -compile(no_auto_import). -export([main/0, run/2]). -spec main() -> nil. main() -> start_with_args(gleam@erlang:start_arguments(), fun run/2). -spec run(gleam@option:option(list(binary())), list(binary())) -> nil. run(Module_list, Ignore_tags) -> Test_event_handler = showtime@erlang@event_handler:start(), Test_module_handler = showtime@erlang@module_handler:start( Test_event_handler, fun showtime@erlang@discover:collect_test_functions/1, fun showtime@erlang@runner:run_test_suite/3, Ignore_tags ), Test_event_handler(start_test_run), Modules = showtime@erlang@discover:collect_modules( Test_module_handler, Module_list ), Test_event_handler( {end_test_run, begin _pipe = Modules, gleam@list:length(_pipe) end} ), nil. -spec start_with_args( list(binary()), fun((gleam@option:option(list(binary())), list(binary())) -> nil) ) -> nil. start_with_args(Args, Func) -> _pipe = glint:new(), _pipe@1 = glint:add_command( _pipe, [], mk_runner(Func), [glint@flag:strings( <<"modules"/utf8>>, [], <<"Run only tests in the modules in this list"/utf8>> ), glint@flag:strings( <<"ignore"/utf8>>, [], <<"Ignore tests that are have tags matching a tag in this list"/utf8>> )], <<"Runs test"/utf8>> ), glint:run(_pipe@1, Args). -spec mk_runner( fun((gleam@option:option(list(binary())), list(binary())) -> nil) ) -> fun((glint:command_input()) -> nil). mk_runner(Func) -> fun(Command) -> Module_list@1 = case begin _pipe = erlang:element(3, Command), _pipe@1 = glint@flag:get(_pipe, <<"modules"/utf8>>), gleam@result:unwrap(_pipe@1, {ls, []}) end of {ls, Module_list} -> case Module_list of [] -> none; _ -> {some, Module_list} end; _ -> none end, Ignore_tags@1 = case begin _pipe@2 = erlang:element(3, Command), _pipe@3 = glint@flag:get(_pipe@2, <<"ignore"/utf8>>), gleam@result:unwrap(_pipe@3, {ls, []}) end of {ls, Ignore_tags} -> Ignore_tags; _ -> [] end, Func(Module_list@1, Ignore_tags@1) end.