Sha256: 144555ca1e5585055355f0089ed4dbcbde049627188dd6cdc45b20faa1c207f9

Contents?: true

Size: 1.97 KB

Versions: 2

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.rb is a CLI to http://imagebin.ca
    Example: ./imagebin.rb -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] = "priv"
    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

2 entries across 2 versions & 1 rubygems

Version Path
dougsko-imagebin-0.1.1 bin/imagebin
dougsko-imagebin-0.1.2 bin/imagebin