#!/usr/bin/env perl6 # # oops - oops.moe uploader # (c) ix 2016 # ## INCLUDES use v6; use strict; use Net::Curl; use JSON::Tiny; ## VARS my $oopskey = slurp "%*ENV/.oopsrc"; my %colors = ( 'red' => '', 'reset' => '' ); ## SETUP my $curl = curl_easy_init; err "Failed to initialize libcurl!" unless $curl; ## SUBROUTINES sub err($msg) { # pretty print errors say "{%colors}[ERR]{%colors} $msg"; exit 1; } sub usage() { err "usage: oops [files]"; } sub upload($file) { # upload that shit! curl_easy_setopt($curl, CURLOPT_URL, 'http://oops.moe/upload.php'); curl_easy_setopt($curl, CURLOPT_POSTFIELDS, "key=$oopskey"); curl_easy_setopt($curl, CURLOPT_POSTFIELDS, "file=@$file"); curl_easy_setopt($curl, CURLOPT_POSTFIELDS, 'method="json"'); } sub remove($file) { # remove the file! } sub parse($json) { # parse json } ## EXECUTE sub MAIN($file?) { without $file { usage; } upload $file; } # vim: set ft=perl6 :