-module(go_over@hex@puller). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([run/2]). -export_type([puller/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. ?MODULEDOC(false). -type puller() :: curl | wget | httpie | {mock, binary()}. -file("src/go_over/hex/puller.gleam", 12). ?DOC(false). -spec run(puller(), binary()) -> {ok, binary()} | {error, {integer(), binary()}}. run(Puller, Url) -> case Puller of curl -> go_over@util@util:retry_cmd(<<"curl"/utf8>>, [<<"-sf"/utf8>>, Url]); wget -> go_over@util@util:retry_cmd(<<"wget"/utf8>>, [<<"-qO-"/utf8>>, Url]); httpie -> go_over@util@util:retry_cmd( <<"https"/utf8>>, [<<"--body"/utf8>>, Url] ); {mock, Result_filepath} -> _pipe = simplifile:read(Result_filepath), gleam@result:replace_error(_pipe, {1, <<"Mock Failure"/utf8>>}) end.