Current section
Files
Jump to
Current section
Files
src/ormlette@cli@schema.erl
-module(ormlette@cli@schema).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([find_schema_files/0]).
-file("/Users/ashercohen/Desktop/gleam/ormlette/src/ormlette/cli/schema.gleam", 15).
-spec find_schema_files() -> gleam@option:option(list(binary())).
find_schema_files() ->
_assert_subject = simplifile:current_directory(),
{ok, Cwd} = case _assert_subject of
{ok, _} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"ormlette/cli/schema"/utf8>>,
function => <<"find_schema_files"/utf8>>,
line => 16})
end,
_assert_subject@1 = globlin:new_pattern(
<<Cwd/binary, "/src/schema/*.gleam"/utf8>>
),
{ok, Pattern} = case _assert_subject@1 of
{ok, _} -> _assert_subject@1;
_assert_fail@1 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail@1,
module => <<"ormlette/cli/schema"/utf8>>,
function => <<"find_schema_files"/utf8>>,
line => 18})
end,
case globlin_fs:glob(Pattern, regular_files) of
{ok, Files} ->
_pipe = Files,
_pipe@1 = gleam@list:sort(_pipe, fun gleam@string:compare/2),
_pipe@2 = gleam@list:map(_pipe@1, fun filepath:base_name/1),
_pipe@3 = gleam@list:map(_pipe@2, fun filepath:strip_extension/1),
{some, _pipe@3};
{error, Err} ->
gleam@io:print(<<"File error: "/utf8>>),
gleam@io:debug(Err),
none
end.