diff options
author | HJ <thechairman@thechairman.info> | 2024-02-03 15:09:54 -0500 |
---|---|---|
committer | HJ <thechairman@thechairman.info> | 2024-02-03 15:09:54 -0500 |
commit | 96a3c5c179d8d3fff24eb2953e45f8dd15e2714c (patch) | |
tree | 0a67bc0cfeabe51740bb049c61f16f1ac3bdd4ff /aoc2023/build/dev/erlang/glint | |
parent | 547fe03cf43105f46160e2dd9afff21637eaaf47 (diff) | |
download | gleam_aoc-96a3c5c179d8d3fff24eb2953e45f8dd15e2714c.tar.gz gleam_aoc-96a3c5c179d8d3fff24eb2953e45f8dd15e2714c.zip |
cleanup
Diffstat (limited to 'aoc2023/build/dev/erlang/glint')
23 files changed, 1311 insertions, 0 deletions
diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/gleam@@compile.erl b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/gleam@@compile.erl new file mode 100644 index 0000000..543db88 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/gleam@@compile.erl @@ -0,0 +1,157 @@ +#!/usr/bin/env escript + +% TODO: Don't concurrently print warnings and errors +% TODO: Some tests + +-record(arguments, {lib = "./", out = "./", modules = []}). + +main(Args) -> + #arguments{out = Out, lib = Lib, modules = Modules} = parse(Args), + IsElixirModule = fun(Module) -> + filename:extension(Module) =:= ".ex" + end, + {ElixirModules, ErlangModules} = lists:partition(IsElixirModule, Modules), + ok = configure_logging(), + ok = add_lib_to_erlang_path(Lib), + ok = filelib:ensure_dir([Out, $/]), + {ErlangOk, _ErlangBeams} = compile_erlang(ErlangModules, Out), + {ElixirOk, _ElixirBeams} = case ErlangOk of + true -> compile_elixir(ElixirModules, Out); + false -> {false, []} + end, + case ErlangOk and ElixirOk of + true -> ok; + false -> erlang:halt(1) + end. + +compile_erlang(Modules, Out) -> + Workers = start_compiler_workers(Out), + ok = producer_loop(Modules, Workers), + collect_results({true, []}). + +collect_results(Acc = {Result, Beams}) -> + receive + {compiled, Beam} -> collect_results({Result, [Beam | Beams]}); + failed -> collect_results({false, Beams}) + after 0 -> Acc + end. + +producer_loop([], 0) -> + ok; +producer_loop([], Workers) -> + receive + {work_please, _} -> producer_loop([], Workers - 1) + end; +producer_loop([Module | Modules], Workers) -> + receive + {work_please, Worker} -> + erlang:send(Worker, {module, Module}), + producer_loop(Modules, Workers) + end. + +start_compiler_workers(Out) -> + Parent = self(), + NumSchedulers = erlang:system_info(schedulers), + SpawnWorker = fun(_) -> + erlang:spawn_link(fun() -> worker_loop(Parent, Out) end) + end, + lists:foreach(SpawnWorker, lists:seq(1, NumSchedulers)), + NumSchedulers. + +worker_loop(Parent, Out) -> + Options = [report_errors, report_warnings, debug_info, {outdir, Out}], + erlang:send(Parent, {work_please, self()}), + receive + {module, Module} -> + log({compiling, Module}), + case compile:file(Module, Options) of + {ok, ModuleName} -> + Beam = filename:join(Out, ModuleName) ++ ".beam", + Message = {compiled, Beam}, + log(Message), + erlang:send(Parent, Message); + error -> + log({failed, Module}), + erlang:send(Parent, failed) + end, + worker_loop(Parent, Out) + end. + +compile_elixir(Modules, Out) -> + Error = [ + "The program elixir was not found. Is it installed?", + $\n, + "Documentation for installing Elixir can be viewed here:", + $\n, + "https://elixir-lang.org/install.html" + ], + case Modules of + [] -> {true, []}; + _ -> + log({starting, "compiler.app"}), + ok = application:start(compiler), + log({starting, "elixir.app"}), + case application:start(elixir) of + ok -> do_compile_elixir(Modules, Out); + _ -> + io:put_chars(standard_error, [Error, $\n]), + {false, []} + end + end. + +do_compile_elixir(Modules, Out) -> + ModuleBins = lists:map(fun(Module) -> + log({compiling, Module}), + list_to_binary(Module) + end, Modules), + OutBin = list_to_binary(Out), + Options = [{dest, OutBin}], + % Silence "redefining module" warnings. + % Compiled modules in the build directory are added to the code path. + % These warnings result from recompiling loaded modules. + % TODO: This line can likely be removed if/when the build directory is cleaned before every compilation. + 'Elixir.Code':compiler_options([{ignore_module_conflict, true}]), + case 'Elixir.Kernel.ParallelCompiler':compile_to_path(ModuleBins, OutBin, Options) of + {ok, ModuleAtoms, _} -> + ToBeam = fun(ModuleAtom) -> + Beam = filename:join(Out, atom_to_list(ModuleAtom)) ++ ".beam", + log({compiled, Beam}), + Beam + end, + {true, lists:map(ToBeam, ModuleAtoms)}; + {error, Errors, _} -> + % Log all filenames associated with modules that failed to compile. + % Note: The compiler prints compilation errors upon encountering them. + ErrorFiles = lists:usort([File || {File, _, _} <- Errors]), + Log = fun(File) -> + log({failed, binary_to_list(File)}) + end, + lists:foreach(Log, ErrorFiles), + {false, []}; + _ -> {false, []} + end. + +add_lib_to_erlang_path(Lib) -> + code:add_paths(filelib:wildcard([Lib, "/*/ebin"])). + +parse(Args) -> + parse(Args, #arguments{}). + +parse([], Arguments) -> + Arguments; +parse(["--lib", Lib | Rest], Arguments) -> + parse(Rest, Arguments#arguments{lib = Lib}); +parse(["--out", Out | Rest], Arguments) -> + parse(Rest, Arguments#arguments{out = Out}); +parse([Module | Rest], Arguments = #arguments{modules = Modules}) -> + parse(Rest, Arguments#arguments{modules = [Module | Modules]}). + +configure_logging() -> + Enabled = os:getenv("GLEAM_LOG") /= false, + persistent_term:put(gleam_logging_enabled, Enabled). + +log(Term) -> + case persistent_term:get(gleam_logging_enabled) of + true -> erlang:display(Term), ok; + false -> ok + end. diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.cache b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.cache Binary files differnew file mode 100644 index 0000000..d1a66cb --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.cache diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.cache_meta b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.cache_meta Binary files differnew file mode 100644 index 0000000..23d66d7 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.cache_meta diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.erl b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.erl new file mode 100644 index 0000000..13ae369 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint.erl @@ -0,0 +1,513 @@ +-module(glint). +-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). + +-export([with_config/2, with_pretty_help/2, without_pretty_help/1, with_name/2, new/0, command/1, description/2, flag/3, flag_tuple/2, flags/2, global_flag/3, global_flag_tuple/2, global_flags/2, default_pretty_help/0, add/3, help_flag/0, execute/2, run_and_handle/3, run/2, add_command_from_stub/2]). +-export_type([config/0, pretty_help/0, glint/1, command/1, command_input/0, command_node/1, out/1, stub/1]). + +-type config() :: {config, + gleam@option:option(pretty_help()), + gleam@option:option(binary())}. + +-type pretty_help() :: {pretty_help, + gleam_community@colour:colour(), + gleam_community@colour:colour(), + gleam_community@colour:colour()}. + +-opaque glint(JFP) :: {glint, + config(), + command_node(JFP), + gleam@dict:dict(binary(), glint@flag:flag())}. + +-opaque command(JFQ) :: {command, + fun((command_input()) -> JFQ), + gleam@dict:dict(binary(), glint@flag:flag()), + binary()}. + +-type command_input() :: {command_input, + list(binary()), + gleam@dict:dict(binary(), glint@flag:flag())}. + +-type command_node(JFR) :: {command_node, + gleam@option:option(command(JFR)), + gleam@dict:dict(binary(), command_node(JFR))}. + +-type out(JFS) :: {out, JFS} | {help, binary()}. + +-type stub(JFT) :: {stub, + list(binary()), + fun((command_input()) -> JFT), + list({binary(), glint@flag:flag()}), + binary()}. + +-spec with_config(glint(JFY), config()) -> glint(JFY). +with_config(Glint, Config) -> + erlang:setelement(2, Glint, Config). + +-spec with_pretty_help(glint(JGB), pretty_help()) -> glint(JGB). +with_pretty_help(Glint, Pretty) -> + _pipe = erlang:setelement(2, erlang:element(2, Glint), {some, Pretty}), + with_config(Glint, _pipe). + +-spec without_pretty_help(glint(JGE)) -> glint(JGE). +without_pretty_help(Glint) -> + _pipe = erlang:setelement(2, erlang:element(2, Glint), none), + with_config(Glint, _pipe). + +-spec with_name(glint(JGH), binary()) -> glint(JGH). +with_name(Glint, Name) -> + _pipe = erlang:setelement(3, erlang:element(2, Glint), {some, Name}), + with_config(Glint, _pipe). + +-spec empty_command() -> command_node(any()). +empty_command() -> + {command_node, none, gleam@map:new()}. + +-spec new() -> glint(any()). +new() -> + {glint, {config, none, none}, empty_command(), gleam@map:new()}. + +-spec do_add(command_node(JGR), list(binary()), command(JGR)) -> command_node(JGR). +do_add(Root, Path, Contents) -> + case Path of + [] -> + erlang:setelement(2, Root, {some, Contents}); + + [X | Xs] -> + erlang:setelement( + 3, + Root, + (gleam@map:update( + erlang:element(3, Root), + X, + fun(Node) -> _pipe = Node, + _pipe@1 = gleam@option:lazy_unwrap( + _pipe, + fun empty_command/0 + ), + do_add(_pipe@1, Xs, Contents) end + )) + ) + end. + +-spec command(fun((command_input()) -> JHA)) -> command(JHA). +command(Runner) -> + {command, Runner, gleam@map:new(), <<""/utf8>>}. + +-spec description(command(JHD), binary()) -> command(JHD). +description(Cmd, Description) -> + erlang:setelement(4, Cmd, Description). + +-spec flag(command(JHG), binary(), glint@flag:flag_builder(any())) -> command(JHG). +flag(Cmd, Key, Flag) -> + erlang:setelement( + 3, + Cmd, + gleam@map:insert(erlang:element(3, Cmd), Key, glint@flag:build(Flag)) + ). + +-spec flag_tuple(command(JHL), {binary(), glint@flag:flag_builder(any())}) -> command(JHL). +flag_tuple(Cmd, Tup) -> + flag(Cmd, erlang:element(1, Tup), erlang:element(2, Tup)). + +-spec flags(command(JHQ), list({binary(), glint@flag:flag()})) -> command(JHQ). +flags(Cmd, Flags) -> + gleam@list:fold( + Flags, + Cmd, + fun(Cmd@1, _use1) -> + {Key, Flag} = _use1, + erlang:setelement( + 3, + Cmd@1, + gleam@map:insert(erlang:element(3, Cmd@1), Key, Flag) + ) + end + ). + +-spec global_flag(glint(JHU), binary(), glint@flag:flag_builder(any())) -> glint(JHU). +global_flag(Glint, Key, Flag) -> + erlang:setelement( + 4, + Glint, + gleam@map:insert(erlang:element(4, Glint), Key, glint@flag:build(Flag)) + ). + +-spec global_flag_tuple(glint(JHZ), {binary(), glint@flag:flag_builder(any())}) -> glint(JHZ). +global_flag_tuple(Glint, Tup) -> + global_flag(Glint, erlang:element(1, Tup), erlang:element(2, Tup)). + +-spec global_flags(glint(JIE), list({binary(), glint@flag:flag()})) -> glint(JIE). +global_flags(Glint, Flags) -> + erlang:setelement( + 4, + Glint, + (gleam@list:fold( + Flags, + erlang:element(4, Glint), + fun(Acc, Tup) -> + gleam@map:insert( + Acc, + erlang:element(1, Tup), + erlang:element(2, Tup) + ) + end + )) + ). + +-spec execute_root( + command_node(JIS), + gleam@dict:dict(binary(), glint@flag:flag()), + list(binary()), + list(binary()) +) -> {ok, out(JIS)} | {error, snag:snag()}. +execute_root(Cmd, Global_flags, Args, Flag_inputs) -> + _pipe@3 = case erlang:element(2, Cmd) of + {some, Contents} -> + gleam@result:'try'( + gleam@list:try_fold( + Flag_inputs, + gleam@map:merge(Global_flags, erlang:element(3, Contents)), + fun glint@flag:update_flags/2 + ), + fun(New_flags) -> _pipe = {command_input, Args, New_flags}, + _pipe@1 = (erlang:element(2, Contents))(_pipe), + _pipe@2 = {out, _pipe@1}, + {ok, _pipe@2} end + ); + + none -> + snag:error(<<"command not found"/utf8>>) + end, + snag:context(_pipe@3, <<"failed to run command"/utf8>>). + +-spec default_pretty_help() -> pretty_help(). +default_pretty_help() -> + _assert_subject = gleam_community@colour:from_rgb255(182, 255, 234), + {ok, Usage_colour} = case _assert_subject of + {ok, _} -> _assert_subject; + _assert_fail -> + erlang:error(#{gleam_error => let_assert, + message => <<"Assertion pattern match failed"/utf8>>, + value => _assert_fail, + module => <<"glint"/utf8>>, + function => <<"default_pretty_help"/utf8>>, + line => 404}) + end, + _assert_subject@1 = gleam_community@colour:from_rgb255(255, 175, 243), + {ok, Flags_colour} = case _assert_subject@1 of + {ok, _} -> _assert_subject@1; + _assert_fail@1 -> + erlang:error(#{gleam_error => let_assert, + message => <<"Assertion pattern match failed"/utf8>>, + value => _assert_fail@1, + module => <<"glint"/utf8>>, + function => <<"default_pretty_help"/utf8>>, + line => 405}) + end, + _assert_subject@2 = gleam_community@colour:from_rgb255(252, 226, 174), + {ok, Subcommands_colour} = case _assert_subject@2 of + {ok, _} -> _assert_subject@2; + _assert_fail@2 -> + erlang:error(#{gleam_error => let_assert, + message => <<"Assertion pattern match failed"/utf8>>, + value => _assert_fail@2, + module => <<"glint"/utf8>>, + function => <<"default_pretty_help"/utf8>>, + line => 406}) + end, + {pretty_help, Usage_colour, Flags_colour, Subcommands_colour}. + +-spec is_not_empty(binary()) -> boolean(). +is_not_empty(S) -> + S /= <<""/utf8>>. + +-spec sanitize_path(list(binary())) -> list(binary()). +sanitize_path(Path) -> + _pipe = Path, + _pipe@1 = gleam@list:map(_pipe, fun gleam@string:trim/1), + gleam@list:filter(_pipe@1, fun is_not_empty/1). + +-spec add(glint(JGM), list(binary()), command(JGM)) -> glint(JGM). +add(Glint, Path, Contents) -> + erlang:setelement( + 3, + Glint, + begin + _pipe = Path, + _pipe@1 = sanitize_path(_pipe), + do_add(erlang:element(3, Glint), _pipe@1, Contents) + end + ). + +-spec help_flag() -> binary(). +help_flag() -> + <<(<<"--"/utf8>>)/binary, "help"/utf8>>. + +-spec wrap_with_space(binary()) -> binary(). +wrap_with_space(S) -> + case S of + <<""/utf8>> -> + <<" "/utf8>>; + + _ -> + <<<<" "/utf8, S/binary>>/binary, " "/utf8>> + end. + +-spec subcommand_help(binary(), command_node(any())) -> binary(). +subcommand_help(Name, Cmd) -> + case erlang:element(2, Cmd) of + none -> + Name; + + {some, Contents} -> + <<<<Name/binary, "\t\t"/utf8>>/binary, + (erlang:element(4, Contents))/binary>> + end. + +-spec subcommands_help(gleam@dict:dict(binary(), command_node(any()))) -> binary(). +subcommands_help(Cmds) -> + _pipe = Cmds, + _pipe@1 = gleam@map:map_values(_pipe, fun subcommand_help/2), + _pipe@2 = gleam@map:values(_pipe@1), + _pipe@3 = gleam@list:sort(_pipe@2, fun gleam@string:compare/2), + gleam@string:join(_pipe@3, <<"\n\t"/utf8>>). + +-spec heading_style(binary(), gleam_community@colour:colour()) -> binary(). +heading_style(Heading, Colour) -> + _pipe = Heading, + _pipe@1 = gleam_community@ansi:bold(_pipe), + _pipe@2 = gleam_community@ansi:underline(_pipe@1), + _pipe@3 = gleam_community@ansi:italic(_pipe@2), + _pipe@4 = gleam_community@ansi:hex( + _pipe@3, + gleam_community@colour:to_rgb_hex(Colour) + ), + gleam_community@ansi:reset(_pipe@4). + +-spec usage_help( + binary(), + gleam@dict:dict(binary(), glint@flag:flag()), + config() +) -> binary(). +usage_help(Cmd_name, Flags, Config) -> + App_name = gleam@option:unwrap( + erlang:element(3, Config), + <<"gleam run"/utf8>> + ), + Flags@1 = begin + _pipe = Flags, + _pipe@1 = gleam@map:to_list(_pipe), + _pipe@2 = gleam@list:map(_pipe@1, fun glint@flag:flag_type_help/1), + gleam@list:sort(_pipe@2, fun gleam@string:compare/2) + end, + Flag_sb = case Flags@1 of + [] -> + gleam@string_builder:new(); + + _ -> + _pipe@3 = Flags@1, + _pipe@4 = gleam@list:intersperse(_pipe@3, <<" "/utf8>>), + _pipe@5 = gleam@string_builder:from_strings(_pipe@4), + _pipe@6 = gleam@string_builder:prepend(_pipe@5, <<" [ "/utf8>>), + gleam@string_builder:append(_pipe@6, <<" ]"/utf8>>) + end, + _pipe@7 = [App_name, wrap_with_space(Cmd_name), <<"[ ARGS ]"/utf8>>], + _pipe@8 = gleam@string_builder:from_strings(_pipe@7), + _pipe@9 = gleam@string_builder:append_builder(_pipe@8, Flag_sb), + _pipe@12 = gleam@string_builder:prepend( + _pipe@9, + <<(begin + _pipe@10 = erlang:element(2, Config), + _pipe@11 = gleam@option:map( + _pipe@10, + fun(Styling) -> + heading_style( + <<"USAGE:"/utf8>>, + erlang:element(2, Styling) + ) + end + ), + gleam@option:unwrap(_pipe@11, <<"USAGE:"/utf8>>) + end)/binary, + "\n\t"/utf8>> + ), + gleam@string_builder:to_string(_pipe@12). + +-spec cmd_help( + list(binary()), + command_node(any()), + config(), + gleam@dict:dict(binary(), glint@flag:flag()) +) -> binary(). +cmd_help(Path, Cmd, Config, Global_flags) -> + Name = begin + _pipe = Path, + _pipe@1 = gleam@list:reverse(_pipe), + gleam@string:join(_pipe@1, <<" "/utf8>>) + end, + Flags = begin + _pipe@2 = gleam@option:map( + erlang:element(2, Cmd), + fun(Contents) -> erlang:element(3, Contents) end + ), + _pipe@3 = gleam@option:lazy_unwrap(_pipe@2, fun gleam@map:new/0), + gleam@map:merge(Global_flags, _pipe@3) + end, + Flags_help_body = <<<<(begin + _pipe@4 = erlang:element(2, Config), + _pipe@5 = gleam@option:map( + _pipe@4, + fun(P) -> + heading_style(<<"FLAGS:"/utf8>>, erlang:element(3, P)) + end + ), + gleam@option:unwrap(_pipe@5, <<"FLAGS:"/utf8>>) + end)/binary, + "\n\t"/utf8>>/binary, + (gleam@string:join( + gleam@list:sort( + [<<"--help\t\t\tPrint help information"/utf8>> | + glint@flag:flags_help(Flags)], + fun gleam@string:compare/2 + ), + <<"\n\t"/utf8>> + ))/binary>>, + Usage = usage_help(Name, Flags, Config), + Description = begin + _pipe@6 = erlang:element(2, Cmd), + _pipe@7 = gleam@option:map( + _pipe@6, + fun(Contents@1) -> erlang:element(4, Contents@1) end + ), + gleam@option:unwrap(_pipe@7, <<""/utf8>>) + end, + Header_items = begin + _pipe@8 = [Name, Description], + _pipe@9 = gleam@list:filter(_pipe@8, fun is_not_empty/1), + gleam@string:join(_pipe@9, <<"\n"/utf8>>) + end, + Subcommands = case subcommands_help(erlang:element(3, Cmd)) of + <<""/utf8>> -> + <<""/utf8>>; + + Subcommands_help_body -> + <<<<(begin + _pipe@10 = erlang:element(2, Config), + _pipe@11 = gleam@option:map( + _pipe@10, + fun(P@1) -> + heading_style( + <<"SUBCOMMANDS:"/utf8>>, + erlang:element(4, P@1) + ) + end + ), + gleam@option:unwrap(_pipe@11, <<"SUBCOMMANDS:"/utf8>>) + end)/binary, + "\n\t"/utf8>>/binary, + Subcommands_help_body/binary>> + end, + _pipe@12 = [Header_items, Usage, Flags_help_body, Subcommands], + _pipe@13 = gleam@list:filter(_pipe@12, fun is_not_empty/1), + gleam@string:join(_pipe@13, <<"\n\n"/utf8>>). + +-spec do_execute( + command_node(JIM), + config(), + gleam@dict:dict(binary(), glint@flag:flag()), + list(binary()), + list(binary()), + boolean(), + list(binary()) +) -> {ok, out(JIM)} | {error, snag:snag()}. +do_execute(Cmd, Config, Global_flags, Args, Flags, Help, Command_path) -> + case Args of + [] when Help -> + _pipe = Command_path, + _pipe@1 = cmd_help(_pipe, Cmd, Config, Global_flags), + _pipe@2 = {help, _pipe@1}, + {ok, _pipe@2}; + + [] -> + execute_root(Cmd, Global_flags, [], Flags); + + [Arg | Rest] -> + case gleam@map:get(erlang:element(3, Cmd), Arg) of + {ok, Cmd@1} -> + do_execute( + Cmd@1, + Config, + Global_flags, + Rest, + Flags, + Help, + [Arg | Command_path] + ); + + _ when Help -> + _pipe@3 = Command_path, + _pipe@4 = cmd_help(_pipe@3, Cmd, Config, Global_flags), + _pipe@5 = {help, _pipe@4}, + {ok, _pipe@5}; + + _ -> + execute_root(Cmd, Global_flags, Args, Flags) + end + end. + +-spec execute(glint(JII), list(binary())) -> {ok, out(JII)} | + {error, snag:snag()}. +execute(Glint, Args) -> + Help_flag = help_flag(), + {Help, Args@2} = case gleam@list:pop(Args, fun(S) -> S =:= Help_flag end) of + {ok, {_, Args@1}} -> + {true, Args@1}; + + _ -> + {false, Args} + end, + {Flags, Args@3} = gleam@list:partition( + Args@2, + fun(_capture) -> gleam@string:starts_with(_capture, <<"--"/utf8>>) end + ), + do_execute( + erlang:element(3, Glint), + erlang:element(2, Glint), + erlang:element(4, Glint), + Args@3, + Flags, + Help, + [] + ). + +-spec run_and_handle(glint(JJA), list(binary()), fun((JJA) -> any())) -> nil. +run_and_handle(Glint, Args, Handle) -> + case execute(Glint, Args) of + {error, Err} -> + _pipe = Err, + _pipe@1 = snag:pretty_print(_pipe), + gleam@io:println(_pipe@1); + + {ok, {help, Help}} -> + gleam@io:println(Help); + + {ok, {out, Out}} -> + Handle(Out), + nil + end. + +-spec run(glint(any()), list(binary())) -> nil. +run(Glint, Args) -> + run_and_handle(Glint, Args, gleam@function:constant(nil)). + +-spec add_command_from_stub(glint(JJN), stub(JJN)) -> glint(JJN). +add_command_from_stub(Glint, Stub) -> + add( + Glint, + erlang:element(2, Stub), + begin + _pipe = command(erlang:element(3, Stub)), + _pipe@1 = flags(_pipe, erlang:element(4, Stub)), + description(_pipe@1, erlang:element(5, Stub)) + end + ). diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.cache b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.cache Binary files differnew file mode 100644 index 0000000..90aed37 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.cache diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.cache_meta b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.cache_meta Binary files differnew file mode 100644 index 0000000..be367e3 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.cache_meta diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.erl b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.erl new file mode 100644 index 0000000..634b37b --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag.erl @@ -0,0 +1,523 @@ +-module(glint@flag). +-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). + +-export([string/0, string_list/0, build/1, constraint/2, description/2, default/2, build_map/1, int/0, int_list/0, float/0, float_list/0, bool/0, flag_type_help/1, flags_help/1, update_flags/2, get_int_value/1, get_int/2, get_ints_value/1, get_ints/2, get_bool_value/1, get_bool/2, get_string_value/1, get_string/2, get_strings_value/1, get_strings/2, get_float_value/1, get_float/2, get_floats_value/1, get_floats/2]). +-export_type([value/0, flag_builder/1, internal/1, flag/0]). + +-type value() :: {b, internal(boolean())} | + {i, internal(integer())} | + {li, internal(list(integer()))} | + {f, internal(float())} | + {lf, internal(list(float()))} | + {s, internal(binary())} | + {ls, internal(list(binary()))}. + +-opaque flag_builder(IRX) :: {flag_builder, + binary(), + fun((binary()) -> {ok, IRX} | {error, snag:snag()}), + fun((internal(IRX)) -> value()), + gleam@option:option(IRX)}. + +-opaque internal(IRY) :: {internal, + gleam@option:option(IRY), + fun((binary()) -> {ok, IRY} | {error, snag:snag()})}. + +-type flag() :: {flag, value(), binary()}. + +-spec new( + fun((internal(ISP)) -> value()), + fun((binary()) -> {ok, ISP} | {error, snag:snag()}) +) -> flag_builder(ISP). +new(Valuer, P) -> + {flag_builder, <<""/utf8>>, P, Valuer, none}. + +-spec string() -> flag_builder(binary()). +string() -> + new(fun(Field@0) -> {s, Field@0} end, fun(S) -> {ok, S} end). + +-spec string_list() -> flag_builder(list(binary())). +string_list() -> + new(fun(Field@0) -> {ls, Field@0} end, fun(Input) -> _pipe = Input, + _pipe@1 = gleam@string:split(_pipe, <<","/utf8>>), + {ok, _pipe@1} end). + +-spec build(flag_builder(any())) -> flag(). +build(Fb) -> + {flag, + (erlang:element(4, Fb))( + {internal, erlang:element(5, Fb), erlang:element(3, Fb)} + ), + erlang:element(2, Fb)}. + +-spec attempt( + {ok, ITG} | {error, ITH}, + fun((ITG) -> {ok, any()} | {error, ITH}) +) -> {ok, ITG} | {error, ITH}. +attempt(Val, F) -> + gleam@result:'try'(Val, fun(A) -> gleam@result:replace(F(A), A) end). + +-spec wrap_with_constraint( + fun((binary()) -> {ok, ITA} | {error, snag:snag()}), + fun((ITA) -> {ok, nil} | {error, snag:snag()}) +) -> fun((binary()) -> {ok, ITA} | {error, snag:snag()}). +wrap_with_constraint(P, Constraint) -> + fun(Input) -> attempt(P(Input), Constraint) end. + +-spec constraint( + flag_builder(ISW), + fun((ISW) -> {ok, nil} | {error, snag:snag()}) +) -> flag_builder(ISW). +constraint(Builder, Constraint) -> + erlang:setelement( + 3, + Builder, + wrap_with_constraint(erlang:element(3, Builder), Constraint) + ). + +-spec description(flag_builder(ITP), binary()) -> flag_builder(ITP). +description(Builder, Description) -> + erlang:setelement(2, Builder, Description). + +-spec default(flag_builder(ITS), ITS) -> flag_builder(ITS). +default(Builder, Default) -> + erlang:setelement(5, Builder, {some, Default}). + +-spec build_map(list({binary(), flag()})) -> gleam@dict:dict(binary(), flag()). +build_map(Flags) -> + gleam@map:from_list(Flags). + +-spec access_type_error(binary()) -> {ok, any()} | {error, snag:snag()}. +access_type_error(Flag_type) -> + snag:error(<<"cannot access flag as "/utf8, Flag_type/binary>>). + +-spec flag_not_provided_error() -> {ok, any()} | {error, snag:snag()}. +flag_not_provided_error() -> + snag:error(<<"no value provided"/utf8>>). + +-spec construct_value(binary(), internal(IUC), fun((internal(IUC)) -> value())) -> {ok, + value()} | + {error, snag:snag()}. +construct_value(Input, Internal, Constructor) -> + gleam@result:map( + (erlang:element(3, Internal))(Input), + fun(Val) -> Constructor(erlang:setelement(2, Internal, {some, Val})) end + ). + +-spec compute_flag(binary(), value()) -> {ok, value()} | {error, snag:snag()}. +compute_flag(Input, Current) -> + _pipe = Input, + _pipe@1 = case Current of + {i, Internal} -> + fun(_capture) -> + construct_value( + _capture, + Internal, + fun(Field@0) -> {i, Field@0} end + ) + end; + + {li, Internal@1} -> + fun(_capture@1) -> + construct_value( + _capture@1, + Internal@1, + fun(Field@0) -> {li, Field@0} end + ) + end; + + {f, Internal@2} -> + fun(_capture@2) -> + construct_value( + _capture@2, + Internal@2, + fun(Field@0) -> {f, Field@0} end + ) + end; + + {lf, Internal@3} -> + fun(_capture@3) -> + construct_value( + _capture@3, + Internal@3, + fun(Field@0) -> {lf, Field@0} end + ) + end; + + {s, Internal@4} -> + fun(_capture@4) -> + construct_value( + _capture@4, + Internal@4, + fun(Field@0) -> {s, Field@0} end + ) + end; + + {ls, Internal@5} -> + fun(_capture@5) -> + construct_value( + _capture@5, + Internal@5, + fun(Field@0) -> {ls, Field@0} end + ) + end; + + {b, Internal@6} -> + fun(_capture@6) -> + construct_value( + _capture@6, + Internal@6, + fun(Field@0) -> {b, Field@0} end + ) + end + end(_pipe), + snag:context(_pipe@1, <<"failed to compute value for flag"/utf8>>). + +-spec layer_invalid_flag(snag:snag(), binary()) -> snag:snag(). +layer_invalid_flag(Err, Flag) -> + snag:layer(Err, <<<<"invalid flag '"/utf8, Flag/binary>>/binary, "'"/utf8>>). + +-spec no_value_flag_err(binary()) -> snag:snag(). +no_value_flag_err(Flag_input) -> + _pipe = (<<<<"flag '"/utf8, Flag_input/binary>>/binary, + "' has no assigned value"/utf8>>), + _pipe@1 = snag:new(_pipe), + layer_invalid_flag(_pipe@1, Flag_input). + +-spec undefined_flag_err(binary()) -> snag:snag(). +undefined_flag_err(Key) -> + _pipe = <<"flag provided but not defined"/utf8>>, + _pipe@1 = snag:new(_pipe), + layer_invalid_flag(_pipe@1, Key). + +-spec cannot_parse(binary(), binary()) -> snag:snag(). +cannot_parse(Value, Kind) -> + _pipe = (<<<<<<"cannot parse value '"/utf8, Value/binary>>/binary, + "' as "/utf8>>/binary, + Kind/binary>>), + snag:new(_pipe). + +-spec int() -> flag_builder(integer()). +int() -> + new(fun(Field@0) -> {i, Field@0} end, fun(Input) -> _pipe = Input, + _pipe@1 = gleam@int:parse(_pipe), + gleam@result:replace_error( + _pipe@1, + cannot_parse(Input, <<"int"/utf8>>) + ) end). + +-spec int_list() -> flag_builder(list(integer())). +int_list() -> + new(fun(Field@0) -> {li, Field@0} end, fun(Input) -> _pipe = Input, + _pipe@1 = gleam@string:split(_pipe, <<","/utf8>>), + _pipe@2 = gleam@list:try_map(_pipe@1, fun gleam@int:parse/1), + gleam@result:replace_error( + _pipe@2, + cannot_parse(Input, <<"int list"/utf8>>) + ) end). + +-spec float() -> flag_builder(float()). +float() -> + new(fun(Field@0) -> {f, Field@0} end, fun(Input) -> _pipe = Input, + _pipe@1 = gleam@float:parse(_pipe), + gleam@result:replace_error( + _pipe@1, + cannot_parse(Input, <<"float"/utf8>>) + ) end). + +-spec float_list() -> flag_builder(list(float())). +float_list() -> + new(fun(Field@0) -> {lf, Field@0} end, fun(Input) -> _pipe = Input, + _pipe@1 = gleam@string:split(_pipe, <<","/utf8>>), + _pipe@2 = gleam@list:try_map(_pipe@1, fun gleam@float:parse/1), + gleam@result:replace_error( + _pipe@2, + cannot_parse(Input, <<"float list"/utf8>>) + ) end). + +-spec bool() -> flag_builder(boolean()). +bool() -> + new( + fun(Field@0) -> {b, Field@0} end, + fun(Input) -> case gleam@string:lowercase(Input) of + <<"true"/utf8>> -> + {ok, true}; + + <<"t"/utf8>> -> + {ok, true}; + + <<"false"/utf8>> -> + {ok, false}; + + <<"f"/utf8>> -> + {ok, false}; + + _ -> + {error, cannot_parse(Input, <<"bool"/utf8>>)} + end end + ). + +-spec flag_type_help({binary(), flag()}) -> binary(). +flag_type_help(Flag) -> + {Name, Contents} = Flag, + Kind = case erlang:element(2, Contents) of + {i, _} -> + <<"INT"/utf8>>; + + {b, _} -> + <<"BOOL"/utf8>>; + + {f, _} -> + <<"FLOAT"/utf8>>; + + {lf, _} -> + <<"FLOAT_LIST"/utf8>>; + + {li, _} -> + <<"INT_LIST"/utf8>>; + + {ls, _} -> + <<"STRING_LIST"/utf8>>; + + {s, _} -> + <<"STRING"/utf8>> + end, + <<<<<<<<<<"--"/utf8, Name/binary>>/binary, "="/utf8>>/binary, "<"/utf8>>/binary, + Kind/binary>>/binary, + ">"/utf8>>. + +-spec flag_help({binary(), flag()}) -> binary(). +flag_help(Flag) -> + <<<<(flag_type_help(Flag))/binary, "\t\t"/utf8>>/binary, + (erlang:element(3, (erlang:element(2, Flag))))/binary>>. + +-spec flags_help(gleam@dict:dict(binary(), flag())) -> list(binary()). +flags_help(Flags) -> + _pipe = Flags, + _pipe@1 = gleam@map:to_list(_pipe), + gleam@list:map(_pipe@1, fun flag_help/1). + +-spec access(gleam@dict:dict(binary(), flag()), binary()) -> {ok, flag()} | + {error, snag:snag()}. +access(Flags, Name) -> + _pipe = gleam@map:get(Flags, Name), + gleam@result:replace_error(_pipe, undefined_flag_err(Name)). + +-spec update_flag_value(gleam@dict:dict(binary(), flag()), {binary(), binary()}) -> {ok, + gleam@dict:dict(binary(), flag())} | + {error, snag:snag()}. +update_flag_value(Flags, Data) -> + {Key, Input} = Data, + gleam@result:'try'( + access(Flags, Key), + fun(Contents) -> + gleam@result:map( + begin + _pipe = compute_flag(Input, erlang:element(2, Contents)), + gleam@result:map_error( + _pipe, + fun(_capture) -> layer_invalid_flag(_capture, Key) end + ) + end, + fun(Value) -> + gleam@map:insert( + Flags, + Key, + erlang:setelement(2, Contents, Value) + ) + end + ) + end + ). + +-spec attempt_toggle_flag(gleam@dict:dict(binary(), flag()), binary()) -> {ok, + gleam@dict:dict(binary(), flag())} | + {error, snag:snag()}. +attempt_toggle_flag(Flags, Key) -> + gleam@result:'try'( + access(Flags, Key), + fun(Contents) -> case erlang:element(2, Contents) of + {b, {internal, none, _} = Internal} -> + _pipe = erlang:setelement(2, Internal, {some, true}), + _pipe@1 = {b, _pipe}, + _pipe@2 = (fun(Val) -> + erlang:setelement(2, Contents, Val) + end)(_pipe@1), + _pipe@3 = gleam@map:insert(Flags, Key, _pipe@2), + {ok, _pipe@3}; + + {b, {internal, {some, Val@1}, _} = Internal@1} -> + _pipe@4 = erlang:setelement( + 2, + Internal@1, + {some, not Val@1} + ), + _pipe@5 = {b, _pipe@4}, + _pipe@6 = (fun(Val@2) -> + erlang:setelement(2, Contents, Val@2) + end)(_pipe@5), + _pipe@7 = gleam@map:insert(Flags, Key, _pipe@6), + {ok, _pipe@7}; + + _ -> + {error, no_value_flag_err(Key)} + end end + ). + +-spec update_flags(gleam@dict:dict(binary(), flag()), binary()) -> {ok, + gleam@dict:dict(binary(), flag())} | + {error, snag:snag()}. +update_flags(Flags, Flag_input) -> + Flag_input@1 = gleam@string:drop_left( + Flag_input, + gleam@string:length(<<"--"/utf8>>) + ), + case gleam@string:split_once(Flag_input@1, <<"="/utf8>>) of + {ok, Data} -> + update_flag_value(Flags, Data); + + {error, _} -> + attempt_toggle_flag(Flags, Flag_input@1) + end. + +-spec get_value( + gleam@dict:dict(binary(), flag()), + binary(), + fun((flag()) -> {ok, IUK} | {error, snag:snag()}) +) -> {ok, IUK} | {error, snag:snag()}. +get_value(Flags, Key, Kind) -> + _pipe = access(Flags, Key), + _pipe@1 = gleam@result:'try'(_pipe, Kind), + snag:context( + _pipe@1, + <<<<"failed to retrieve value for flag '"/utf8, Key/binary>>/binary, + "'"/utf8>> + ). + +-spec get_int_value(flag()) -> {ok, integer()} | {error, snag:snag()}. +get_int_value(Flag) -> + case erlang:element(2, Flag) of + {i, {internal, {some, Val}, _}} -> + {ok, Val}; + + {i, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"int"/utf8>>) + end. + +-spec get_int(gleam@dict:dict(binary(), flag()), binary()) -> {ok, integer()} | + {error, snag:snag()}. +get_int(Flags, Name) -> + get_value(Flags, Name, fun get_int_value/1). + +-spec get_ints_value(flag()) -> {ok, list(integer())} | {error, snag:snag()}. +get_ints_value(Flag) -> + case erlang:element(2, Flag) of + {li, {internal, {some, Val}, _}} -> + {ok, Val}; + + {li, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"int list"/utf8>>) + end. + +-spec get_ints(gleam@dict:dict(binary(), flag()), binary()) -> {ok, + list(integer())} | + {error, snag:snag()}. +get_ints(Flags, Name) -> + get_value(Flags, Name, fun get_ints_value/1). + +-spec get_bool_value(flag()) -> {ok, boolean()} | {error, snag:snag()}. +get_bool_value(Flag) -> + case erlang:element(2, Flag) of + {b, {internal, {some, Val}, _}} -> + {ok, Val}; + + {b, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"bool"/utf8>>) + end. + +-spec get_bool(gleam@dict:dict(binary(), flag()), binary()) -> {ok, boolean()} | + {error, snag:snag()}. +get_bool(Flags, Name) -> + get_value(Flags, Name, fun get_bool_value/1). + +-spec get_string_value(flag()) -> {ok, binary()} | {error, snag:snag()}. +get_string_value(Flag) -> + case erlang:element(2, Flag) of + {s, {internal, {some, Val}, _}} -> + {ok, Val}; + + {s, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"string"/utf8>>) + end. + +-spec get_string(gleam@dict:dict(binary(), flag()), binary()) -> {ok, binary()} | + {error, snag:snag()}. +get_string(Flags, Name) -> + get_value(Flags, Name, fun get_string_value/1). + +-spec get_strings_value(flag()) -> {ok, list(binary())} | {error, snag:snag()}. +get_strings_value(Flag) -> + case erlang:element(2, Flag) of + {ls, {internal, {some, Val}, _}} -> + {ok, Val}; + + {ls, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"string list"/utf8>>) + end. + +-spec get_strings(gleam@dict:dict(binary(), flag()), binary()) -> {ok, + list(binary())} | + {error, snag:snag()}. +get_strings(Flags, Name) -> + get_value(Flags, Name, fun get_strings_value/1). + +-spec get_float_value(flag()) -> {ok, float()} | {error, snag:snag()}. +get_float_value(Flag) -> + case erlang:element(2, Flag) of + {f, {internal, {some, Val}, _}} -> + {ok, Val}; + + {f, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"float"/utf8>>) + end. + +-spec get_float(gleam@dict:dict(binary(), flag()), binary()) -> {ok, float()} | + {error, snag:snag()}. +get_float(Flags, Name) -> + get_value(Flags, Name, fun get_float_value/1). + +-spec get_floats_value(flag()) -> {ok, list(float())} | {error, snag:snag()}. +get_floats_value(Flag) -> + case erlang:element(2, Flag) of + {lf, {internal, {some, Val}, _}} -> + {ok, Val}; + + {lf, {internal, none, _}} -> + flag_not_provided_error(); + + _ -> + access_type_error(<<"float list"/utf8>>) + end. + +-spec get_floats(gleam@dict:dict(binary(), flag()), binary()) -> {ok, + list(float())} | + {error, snag:snag()}. +get_floats(Flags, Name) -> + get_value(Flags, Name, fun get_floats_value/1). diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.cache b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.cache Binary files differnew file mode 100644 index 0000000..6881dda --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.cache diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.cache_meta b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.cache_meta Binary files differnew file mode 100644 index 0000000..355567d --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.cache_meta diff --git a/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.erl b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.erl new file mode 100644 index 0000000..52eb319 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/_gleam_artefacts/glint@flag@constraint.erl @@ -0,0 +1,68 @@ +-module(glint@flag@constraint). +-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). + +-export([one_of/1, none_of/1, each/1]). + +-spec one_of(list(IQG)) -> fun((IQG) -> {ok, nil} | {error, snag:snag()}). +one_of(Allowed) -> + Allowed_set = gleam@set:from_list(Allowed), + fun(Val) -> case gleam@set:contains(Allowed_set, Val) of + true -> + {ok, nil}; + + false -> + snag:error( + <<<<<<"invalid value '"/utf8, + (gleam@string:inspect(Val))/binary>>/binary, + "', must be one of: ["/utf8>>/binary, + ((<<(begin + _pipe = Allowed, + _pipe@1 = gleam@list:map( + _pipe, + fun(A) -> + <<<<"'"/utf8, + (gleam@string:inspect(A))/binary>>/binary, + "'"/utf8>> + end + ), + gleam@string:join(_pipe@1, <<", "/utf8>>) + end)/binary, + "]"/utf8>>))/binary>> + ) + end end. + +-spec none_of(list(IQJ)) -> fun((IQJ) -> {ok, nil} | {error, snag:snag()}). +none_of(Disallowed) -> + Disallowed_set = gleam@set:from_list(Disallowed), + fun(Val) -> case gleam@set:contains(Disallowed_set, Val) of + false -> + {ok, nil}; + + true -> + snag:error( + <<<<<<"invalid value '"/utf8, + (gleam@string:inspect(Val))/binary>>/binary, + "', must not be one of: ["/utf8>>/binary, + (((<<(begin + _pipe = Disallowed, + _pipe@1 = gleam@list:map( + _pipe, + fun(A) -> + <<<<"'"/utf8, + (gleam@string:inspect(A))/binary>>/binary, + "'"/utf8>> + end + ), + gleam@string:join(_pipe@1, <<", "/utf8>>) + end)/binary, + "]"/utf8>>)))/binary>> + ) + end end. + +-spec each(fun((IQM) -> {ok, nil} | {error, snag:snag()})) -> fun((list(IQM)) -> {ok, + nil} | + {error, snag:snag()}). +each(Constraint) -> + fun(L) -> _pipe = L, + _pipe@1 = gleam@list:try_map(_pipe, Constraint), + gleam@result:replace(_pipe@1, nil) end. diff --git a/aoc2023/build/dev/erlang/glint/ebin/glint.app b/aoc2023/build/dev/erlang/glint/ebin/glint.app new file mode 100644 index 0000000..41fba79 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/ebin/glint.app @@ -0,0 +1,10 @@ +{application, glint, [ + {vsn, "0.13.0"}, + {applications, [gleam_community_ansi, + gleam_community_colour, + gleam_stdlib, + snag]}, + {description, "Gleam command line argument parsing with basic flag support."}, + {modules, []}, + {registered, []} +]}. diff --git a/aoc2023/build/dev/erlang/glint/ebin/glint.beam b/aoc2023/build/dev/erlang/glint/ebin/glint.beam Binary files differnew file mode 100644 index 0000000..39b9ce7 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/ebin/glint.beam diff --git a/aoc2023/build/dev/erlang/glint/ebin/glint@flag.beam b/aoc2023/build/dev/erlang/glint/ebin/glint@flag.beam Binary files differnew file mode 100644 index 0000000..14b7dec --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/ebin/glint@flag.beam diff --git a/aoc2023/build/dev/erlang/glint/ebin/glint@flag@constraint.beam b/aoc2023/build/dev/erlang/glint/ebin/glint@flag@constraint.beam Binary files differnew file mode 100644 index 0000000..1d36d10 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/ebin/glint@flag@constraint.beam diff --git a/aoc2023/build/dev/erlang/glint/include/glint@flag_Flag.hrl b/aoc2023/build/dev/erlang/glint/include/glint@flag_Flag.hrl new file mode 100644 index 0000000..645cb12 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint@flag_Flag.hrl @@ -0,0 +1 @@ +-record(flag, {value :: glint@flag:value(), description :: binary()}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint@flag_FlagBuilder.hrl b/aoc2023/build/dev/erlang/glint/include/glint@flag_FlagBuilder.hrl new file mode 100644 index 0000000..b5e21a2 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint@flag_FlagBuilder.hrl @@ -0,0 +1,6 @@ +-record(flag_builder, { + desc :: binary(), + parser :: fun((binary()) -> {ok, any()} | {error, snag:snag()}), + value :: fun((glint@flag:internal(any())) -> glint@flag:value()), + default :: gleam@option:option(any()) +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint@flag_Internal.hrl b/aoc2023/build/dev/erlang/glint/include/glint@flag_Internal.hrl new file mode 100644 index 0000000..281bbd0 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint@flag_Internal.hrl @@ -0,0 +1,4 @@ +-record(internal, { + value :: gleam@option:option(any()), + parser :: fun((binary()) -> {ok, any()} | {error, snag:snag()}) +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint_Command.hrl b/aoc2023/build/dev/erlang/glint/include/glint_Command.hrl new file mode 100644 index 0000000..2761365 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint_Command.hrl @@ -0,0 +1,5 @@ +-record(command, { + do :: fun((glint:command_input()) -> any()), + flags :: gleam@dict:dict(binary(), glint@flag:flag()), + description :: binary() +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint_CommandInput.hrl b/aoc2023/build/dev/erlang/glint/include/glint_CommandInput.hrl new file mode 100644 index 0000000..e0e1a81 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint_CommandInput.hrl @@ -0,0 +1,4 @@ +-record(command_input, { + args :: list(binary()), + flags :: gleam@dict:dict(binary(), glint@flag:flag()) +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint_Config.hrl b/aoc2023/build/dev/erlang/glint/include/glint_Config.hrl new file mode 100644 index 0000000..70cf645 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint_Config.hrl @@ -0,0 +1,4 @@ +-record(config, { + pretty_help :: gleam@option:option(glint:pretty_help()), + name :: gleam@option:option(binary()) +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint_Glint.hrl b/aoc2023/build/dev/erlang/glint/include/glint_Glint.hrl new file mode 100644 index 0000000..f14c34c --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint_Glint.hrl @@ -0,0 +1,5 @@ +-record(glint, { + config :: glint:config(), + cmd :: glint:command_node(any()), + global_flags :: gleam@dict:dict(binary(), glint@flag:flag()) +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint_PrettyHelp.hrl b/aoc2023/build/dev/erlang/glint/include/glint_PrettyHelp.hrl new file mode 100644 index 0000000..79bd887 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint_PrettyHelp.hrl @@ -0,0 +1,5 @@ +-record(pretty_help, { + usage :: gleam_community@colour:colour(), + flags :: gleam_community@colour:colour(), + subcommands :: gleam_community@colour:colour() +}). diff --git a/aoc2023/build/dev/erlang/glint/include/glint_Stub.hrl b/aoc2023/build/dev/erlang/glint/include/glint_Stub.hrl new file mode 100644 index 0000000..5aa5d83 --- /dev/null +++ b/aoc2023/build/dev/erlang/glint/include/glint_Stub.hrl @@ -0,0 +1,6 @@ +-record(stub, { + path :: list(binary()), + run :: fun((glint:command_input()) -> any()), + flags :: list({binary(), glint@flag:flag()}), + description :: binary() +}). |