wget
=title class Zef::Service::Shell::wget
=subtitle A wget based implementation of the Fetcher interface
Synopsis
use Zef;
use Zef::Service::Shell::wget;
my $wget = Zef::Service::Shell::wget.new;
my $source = "https://raw.githubusercontent.com/ugexe/zef/main/META6.json";
my $save-to = $*TMPDIR.child("zef-meta6.json");
my $saved-to = $wget.fetch($source, $save-to);
die "Something went wrong" unless $saved-to;
say "Zef META6 from HEAD: ";
say $saved-to.slurp;
Description
Fetcher
class for handling http based URIs using the wget
command.
You probably never want to use this unless its indirectly through Zef::Fetch
;
handling files and spawning processes will generally be easier using core language functionality. This
class exists to provide the means for fetching a file using the Fetcher
interfaces that the e.g. git/file
adapters use.
Methods
method probe
method probe(--> Bool:D)
Returns True
if this module can successfully launch the wget
command.
method fetch-matcher
method fetch-matcher(Str() $uri --> Bool:D)
Returns True
if this module knows how to fetch $uri
, which it decides based on if $uri
starts with http
or https
.
method fetch
method fetch(Str() $uri, IO() $save-as, Supplier :$stdout, Supplier :$stderr --> IO::Path)
Fetches the given $uri
, saving it to $save-to
. A Supplier
can be supplied as :$stdout
and
:$stderr
to receive any output.
On success it returns the IO::Path
where the data was actually saved to. On failure it returns Nil
.