Current section
Files
Jump to
Current section
Files
src/sketch_css@commands@generate.erl
-module(sketch_css@commands@generate).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([css/0]).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/commands/generate.gleam", 40).
-spec dst_flag() -> glint:flag(binary()).
dst_flag() ->
Msg = <<"Define the directory in which styles should be output."/utf8>>,
_pipe = glint:string_flag(<<"dest"/utf8>>),
glint:flag_help(_pipe, Msg).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/commands/generate.gleam", 46).
-spec src_flag() -> glint:flag(binary()).
src_flag() ->
Msg = <<"Define the directory in which styles should be read."/utf8>>,
_pipe = glint:string_flag(<<"src"/utf8>>),
glint:flag_help(_pipe, Msg).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/commands/generate.gleam", 52).
-spec interface_flag() -> glint:flag(binary()).
interface_flag() ->
Msg = <<"Define the directory in which interfaces should be output."/utf8>>,
_pipe = glint:string_flag(<<"interface"/utf8>>),
glint:flag_help(_pipe, Msg).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/commands/generate.gleam", 28).
-spec run_glint(
fun((gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary())) -> nil)
) -> glint:command(nil).
run_glint(Continuation) ->
glint:command_help(
<<"Generate CSS for your gleam_styles.gleam files!"/utf8>>,
fun() ->
glint:flag(
dst_flag(),
fun(Dst) ->
glint:flag(
src_flag(),
fun(Src) ->
glint:flag(
interface_flag(),
fun(Interface) ->
glint:command(
fun(_, _, Flags) ->
Dst@1 = begin
_pipe = Dst(Flags),
gleam@option:from_result(_pipe)
end,
Src@1 = begin
_pipe@1 = Src(Flags),
gleam@option:from_result(
_pipe@1
)
end,
Interface@1 = begin
_pipe@2 = Interface(Flags),
gleam@option:from_result(
_pipe@2
)
end,
Continuation(
Src@1,
Dst@1,
Interface@1
)
end
)
end
)
end
)
end
)
end
).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/commands/generate.gleam", 12).
-spec css() -> glint:command(nil).
css() ->
run_glint(
fun(Src, Dst, Interface) ->
_assert_subject = sketch_css@utils:directories(Src, Dst, Interface),
{ok, Directories} = 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 => <<"sketch_css/commands/generate"/utf8>>,
function => <<"css"/utf8>>,
line => 14})
end,
gleam_stdlib:println(
<<"Compiling Gleam styles files in "/utf8,
(erlang:element(2, Directories))/binary>>
),
gleam_stdlib:println(
<<"Writing CSS files to "/utf8,
(erlang:element(3, Directories))/binary>>
),
gleam_stdlib:println(
<<"Writing interfaces files to "/utf8,
(erlang:element(4, Directories))/binary>>
),
_pipe = sketch_css@generate:stylesheets(Directories),
_pipe@1 = gleam@result:map_error(_pipe, fun snag:line_print/1),
_pipe@2 = gleam@result:map_error(
_pipe@1,
fun gleam_stdlib:println/1
),
_pipe@3 = gleam@result:map(
_pipe@2,
fun(_) ->
gleam_stdlib:println(<<"========="/utf8>>),
gleam_stdlib:println(<<"Done!"/utf8>>)
end
),
gleam@result:unwrap_both(_pipe@3)
end
).