Packages

A compile-time safe database library for Gleam - Ecto-inspired schemas, composable queries, and adapter-based persistence

Current section

Files

Jump to
cquill src cquill.erl
Raw

src/cquill.erl

-module(cquill).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/cquill.gleam").
-export([main/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/cquill.gleam", 26).
?DOC(" Execute a parsed command\n").
-spec execute(cquill@cli@args:command()) -> nil.
execute(Command) ->
case Command of
help ->
gleam_stdlib:println(cquill@cli@args:help_text());
version ->
gleam_stdlib:println(cquill@cli@args:version_text());
{generate, Options} ->
case erlang:element(8, Options) of
true ->
cquill@cli@generate:watch(Options);
false ->
case cquill@cli@generate:run(Options) of
{generate_success, Count} ->
case erlang:element(12, Options) of
false ->
gleam_stdlib:println(
<<<<"Generated "/utf8,
(erlang:integer_to_binary(Count))/binary>>/binary,
" files."/utf8>>
);
true ->
nil
end;
{generate_error, Err} ->
gleam_stdlib:println_error(Err),
erlang:halt(1)
end
end
end.
-file("src/cquill.gleam", 13).
?DOC(" Main entry point for the cquill CLI\n").
-spec main() -> nil.
main() ->
Arguments = erlang:element(4, argv:load()),
case cquill@cli@args:parse(Arguments) of
{ok, Command} ->
execute(Command);
{error, Err} ->
gleam_stdlib:println_error(cquill@cli@args:format_error(Err)),
erlang:halt(1)
end.