-module(olive@cli). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -define(FILEPATH, "src/olive/cli.gleam"). -export([get_options/0]). -export_type([cli_options/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(" The `cli` module holds the list of options the user can pass when launching olive.\n"). -type cli_options() :: {cli_options, integer(), integer(), binary(), olive@logging:log_level(), integer()}. -file("src/olive/cli.gleam", 55). -spec main_port_opt() -> clip@opt:opt(integer()). main_port_opt() -> _pipe = clip@opt:new(<<"main_port"/utf8>>), _pipe@1 = clip@opt:int(_pipe), _pipe@2 = clip@opt:default(_pipe@1, 3000), clip@opt:help(_pipe@2, <<"The port your main server listens to."/utf8>>). -file("src/olive/cli.gleam", 62). -spec proxy_port_opt() -> clip@opt:opt(integer()). proxy_port_opt() -> _pipe = clip@opt:new(<<"proxy_port"/utf8>>), _pipe@1 = clip@opt:int(_pipe), _pipe@2 = clip@opt:default(_pipe@1, 1234), clip@opt:help( _pipe@2, <<"The port the proxy listens to, handled by olive."/utf8>> ). -file("src/olive/cli.gleam", 69). -spec bind_opt() -> clip@opt:opt(binary()). bind_opt() -> _pipe = clip@opt:new(<<"bind"/utf8>>), _pipe@1 = clip@opt:default(_pipe, <<"localhost"/utf8>>), clip@opt:help(_pipe@1, <<"The proxy binding address."/utf8>>). -file("src/olive/cli.gleam", 75). -spec log_opt() -> clip@opt:opt(olive@logging:log_level()). log_opt() -> _pipe = clip@opt:new(<<"log"/utf8>>), _pipe@1 = clip@opt:map(_pipe, fun(V) -> case string:lowercase(V) of <<"error"/utf8>> -> error; <<"errors"/utf8>> -> error; <<"warning"/utf8>> -> warning; <<"warnings"/utf8>> -> warning; <<"none"/utf8>> -> none; <<"nologs"/utf8>> -> none; <<"debug"/utf8>> -> debug; _ -> notice end end), _pipe@2 = clip@opt:default(_pipe@1, notice), clip@opt:help( _pipe@2, <<"Either None, Error, Warning, Notice or Debug to filter logs from olive."/utf8>> ). -file("src/olive/cli.gleam", 92). -spec debounce_in_ms_opt() -> clip@opt:opt(integer()). debounce_in_ms_opt() -> _pipe = clip@opt:new(<<"watch_debounce"/utf8>>), _pipe@1 = clip@opt:int(_pipe), _pipe@2 = clip@opt:default(_pipe@1, 50), clip@opt:help( _pipe@2, <<"Debounce in ms used before triggering a rebuild and client reload. Useful when you have multiple changes in a short period of time."/utf8>> ). -file("src/olive/cli.gleam", 21). -spec get_options() -> {ok, cli_options()} | {error, nil}. get_options() -> case begin _pipe = clip:command( begin clip:parameter( fun(Main_port) -> clip:parameter( fun(Proxy_port) -> clip:parameter( fun(Bind) -> clip:parameter( fun(Log) -> clip:parameter( fun(Debounce_in_ms) -> {cli_options, Main_port, Proxy_port, Bind, Log, Debounce_in_ms} end ) end ) end ) end ) end ) end ), _pipe@1 = clip:opt(_pipe, main_port_opt()), _pipe@2 = clip:opt(_pipe@1, proxy_port_opt()), _pipe@3 = clip:opt(_pipe@2, bind_opt()), _pipe@4 = clip:opt(_pipe@3, log_opt()), _pipe@5 = clip:opt(_pipe@4, debounce_in_ms_opt()), _pipe@6 = clip:help( _pipe@5, clip@help:simple( <<"olive"/utf8>>, <<"Runs a dev proxy for easy live reloading and automatic code changes"/utf8>> ) ), clip:run(_pipe@6, erlang:element(4, argv:load())) end of {ok, Options} -> {ok, Options}; {error, Something_to_show} -> gleam_stdlib:println(Something_to_show), {error, nil} end.