Sha256: 4da87f83cc16eee2f06443e271a3413b82a15c28f51bfb0494266d388ea952ea

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

#!/usr/bin/env ruby
#
#
# CLI to imagebin.ca
#
# Copyright (C) 2009 dougsko
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

require 'rubygems'
require 'optparse'
require 'httpclient'

options = { "t" => "file", 
            "name" => "", 
            "tags" => "", 
            "description" => "", 
            "adult" => "f",
}

opts = OptionParser.new do |opts|
    opts.banner =  "imagebin is a CLI to http://imagebin.ca
    Example: imagebin -f <pic.png>" 

    opts.separator ""
    opts.separator "Options:"

    opts.on("-f <file>", "--file <file>", String, "Use a file for input") do |file|
        options["f"] = file
    end

    opts.on("-n [name]", "--name [name]", String, "Name") do |n|
        options["name"] = n
    end

    opts.on("-t [tags]", "--tags [tags]", String, "Comma separated") do |tags|
        options["tags"] = tags
    end

    opts.on("-d [description]", "--description [description]", String, "Description") do |desc|
        options["description"] = desc
    end

    opts.on("-p", "--private", "Private") do |priv|
        options["adult"] = "t"
    end

    opts.on_tail("-h", "--help", "Show this message") do
        puts opts
        exit
    end
end

opts.parse(ARGV)

clnt = HTTPClient.new("http://imagebin.ca/upload.php")
File.open(options["f"]) do |file|
    options["f"] = file
    puts clnt.post('http://imagebin.ca/upload.php', options).content.match(/http.+?\.html/)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dougsko-imagebin-0.1.7 bin/imagebin