Packages

CLI tool to package a Gleam app as a FreeBSD package, with a service script.

Current section

Files

Jump to
glm_freebsd src glm_freebsd.erl
Raw

src/glm_freebsd.erl

-module(glm_freebsd).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glm_freebsd.gleam").
-export([main/0]).
-export_type([app/0]).
-type app() :: {app, binary(), binary(), binary(), binary()}.
-file("src/glm_freebsd.gleam", 18).
-spec app_dir_path_opt() -> clip@opt:opt(binary()).
app_dir_path_opt() ->
_pipe = clip@opt:new(<<"application"/utf8>>),
_pipe@1 = clip@opt:short(_pipe, <<"a"/utf8>>),
clip@opt:help(
_pipe@1,
<<"gleam target application directory (location of the target app's gleam.toml file)"/utf8>>
).
-file("src/glm_freebsd.gleam", 26).
-spec template_dir_path_opt() -> clip@opt:opt(binary()).
template_dir_path_opt() ->
_pipe = clip@opt:new(<<"templates"/utf8>>),
_pipe@1 = clip@opt:short(_pipe, <<"t"/utf8>>),
_pipe@2 = clip@opt:help(
_pipe@1,
<<"path to custom templates directory"/utf8>>
),
clip@opt:default(_pipe@2, <<"./priv/templates/freebsd"/utf8>>).
-file("src/glm_freebsd.gleam", 33).
-spec output_dir_path_opt() -> clip@opt:opt(binary()).
output_dir_path_opt() ->
_pipe = clip@opt:new(<<"output"/utf8>>),
_pipe@1 = clip@opt:short(_pipe, <<"o"/utf8>>),
clip@opt:help(
_pipe@1,
<<"path to place generated (output) files (will create directory)"/utf8>>
).
-file("src/glm_freebsd.gleam", 39).
-spec staging_dir_path_opt() -> clip@opt:opt(binary()).
staging_dir_path_opt() ->
_pipe = clip@opt:new(<<"staging"/utf8>>),
_pipe@1 = clip@opt:short(_pipe, <<"s"/utf8>>),
clip@opt:help(
_pipe@1,
<<"path to place intermediate (staging) files (will create directory)"/utf8>>
).
-file("src/glm_freebsd.gleam", 47).
-spec command() -> clip:command(app()).
command() ->
_pipe = clip:command(
begin
clip:parameter(
fun(App_dir) ->
clip:parameter(
fun(Templates_dir) ->
clip:parameter(
fun(Staging_dir) ->
clip:parameter(
fun(Output_dir) ->
{app,
App_dir,
Templates_dir,
Staging_dir,
Output_dir}
end
)
end
)
end
)
end
)
end
),
_pipe@1 = clip:opt(_pipe, app_dir_path_opt()),
_pipe@2 = clip:opt(_pipe@1, template_dir_path_opt()),
_pipe@3 = clip:opt(_pipe@2, staging_dir_path_opt()),
clip:opt(_pipe@3, output_dir_path_opt()).
-file("src/glm_freebsd.gleam", 62).
-spec main() -> nil.
main() ->
Result = begin
_pipe = command(),
_pipe@1 = clip:help(
_pipe,
clip@help:simple(
<<"package"/utf8>>,
<<"package target gleam application as a FreeBSD package with service scripts"/utf8>>
)
),
clip:run(_pipe@1, erlang:element(4, argv:load()))
end,
case Result of
{error, E} ->
gleam_stdlib:println_error(E);
{ok, App} ->
case glm_freebsd@packager:run(
erlang:element(2, App),
erlang:element(3, App),
erlang:element(4, App),
erlang:element(5, App)
) of
{error, E@1} ->
gleam_stdlib:println_error(
begin
_pipe@2 = E@1,
gleam@string:inspect(_pipe@2)
end
);
{ok, O} ->
gleam_stdlib:println(O)
end,
nil
end.