-module(sqlode). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/sqlode.gleam"). -export([rewrite_error/2, 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/sqlode.gleam", 48). -spec classify_invocation(list(binary())) -> binary(). classify_invocation(Args) -> case Args of [] -> <<"error: missing subcommand. Run 'sqlode --help' to see available commands."/utf8>>; [First | _] -> case gleam_stdlib:string_starts_with(First, <<"-"/utf8>>) of true -> <<<<"error: unrecognized option '"/utf8, First/binary>>/binary, "'. Run 'sqlode --help' to see available options."/utf8>>; false -> <<<<"error: unknown subcommand '"/utf8, First/binary>>/binary, "'. Run 'sqlode --help' to see available commands."/utf8>> end end. -file("src/sqlode.gleam", 41). ?DOC(false). -spec rewrite_error(list(binary()), binary()) -> binary(). rewrite_error(Args, Original) -> case gleam_stdlib:contains_string(Original, <<"command not found"/utf8>>) of true -> classify_invocation(Args); false -> Original end. -file("src/sqlode.gleam", 7). -spec main() -> nil. main() -> Args = erlang:element(4, argv:load()), case glint:execute(sqlode@cli:app(), Args) of {error, Message} -> gleam_stdlib:println_error(rewrite_error(Args, Message)), init:stop(1); {ok, {help, Text}} -> gleam_stdlib:println(Text); {ok, {out, _}} -> nil end.