App-Wax

 view release on metacpan or  search on metacpan

bin/wax  view on Meta::CPAN


Get the default key bindings for mpv:

    $ wax rg -r '$1' '^#(\S.+)$' https://git.io/JfYlz | sort

=head1 CAVEATS

As with any command-line programs that take URL parameters, care should be
taken to ensure that special shell characters are suitably quoted. As a general
rule, URLs that contain C<&>, C<~>, C<E<lt>>, C<E<gt>>, C<$> etc. should be
quoted in shells on Unix-like systems and quoted with embedded escapes in
Windows C<cmd>/C<command.exe>-like shells.

It's worth checking that a program actually needs waxing. Many command-line
programs already support URLs, e.g:

    $ eog https://upload.wikimedia.org/wikipedia/commons/4/4c/Eye_of_GNOME.png
    $ gedit https://projects.gnome.org/gedit/
    $ gimp https://upload.wikimedia.org/wikipedia/commons/6/6c/Gimpscreen.png
    $ vim https://www.vim.org/

lib/App/Wax.pm  view on Meta::CPAN

    if (defined $downloaded) {
        $self->debug('download (%d): %s', $url_index,  ($downloaded ? 'yes' : 'no'));
    } else {
        my $status = $response->status_line;
        $error = "can't download URL #$url_index ($url) to filename ($filename): $status";
    }

    return $error;
}

# helper for `dump_command`: escape/quote a shell argument on POSIX shells
fun _escape ($arg) {
    # https://stackoverflow.com/a/1250279
    # https://github.com/boazy/any-shell-escape/issues/1#issuecomment-36226734
    $arg =~ s!('{1,})!'"$1"'!g;
    $arg = "'$arg'";
    $arg =~ s{^''|''$}{}g;

    return $arg;
}

method _use_default_directory () {
    # "${XDG_CACHE_HOME:-$HOME/.cache}/wax"
    require File::BaseDir;

lib/App/Wax.pm  view on Meta::CPAN

        return OK;
    }
}

# this is purely for diagnostic purposes, i.e. there's no guarantee
# that the dumped command can be used as a command line. a better
# (but still imperfect/incomplete) implementation would require at
# least two extra modules: Win32::ShellQuote and String::ShellQuote:
# https://rt.cpan.org/Public/Bug/Display.html?id=37348
method dump_command ($args) {
    return join(' ', map { /[^0-9A-Za-z+,.\/:=\@_-]/ ? _escape($_) : $_ } @$args);
}

# takes a URL and returns a $filename => $error pair where
# the filename is the path to the saved file and the error
# is the first error message encountered while trying to download
# and save it
method resolve ($_url) {
    my ($error, $filename, @resolved);

    if ($self->keep) {



( run in 1.288 second using v1.01-cache-2.11-cpan-73692580452 )