Help language development. Donate to The Perl Foundation

App::Nopaste zef:raku-community-modules last updated on 2022-02-25

bin/nopaste
use App::Nopaste;

constant GIST-TOKEN-ERROR = 'Please generate a GitHub token with `gist` '
    ~ 'permission and set PASTEBIN_GIST_TOKEN env var to it';

# Usage
multi MAIN() { say 'Specify URL to fetch or file(s) to paste'; }

# Paste
multi MAIN(*@files) { say App::Nopaste.new.paste( @files ); }

# Fetch
multi MAIN(Str $url where /^ 'http's? '://' [gist|fpaste]/ ) {
    fail GIST-TOKEN-ERROR if $url ~~ /gist/ and not %*ENV<PASTEBIN_GIST_TOKEN>;

    my ($paste, $desc) = App::Nopaste.new.fetch($url);
    say "#### Description: $desc\n$paste";
}

# vim: expandtab shiftwidth=4