#!/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 . # require 'rubygems' require 'optparse' require 'imagebin' options = { "t" => "file", "name" => "", "tags" => "", "description" => "", "adult" => "f", "direct_link" => "0", } opts = OptionParser.new do |opts| opts.banner = "imagebin is a CLI to http://imagebin.ca Example: imagebin -f " opts.separator "" opts.separator "Options:" opts.on("-f ", "--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("-l", "--link", "Direct link to picture file") do |direct_link| options["direct_link"] = "1" end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end opts.parse(ARGV) if options["direct_link"] == "0" options.delete("direct_link") ibin = Imagebin.new(options) puts ibin.site_link elsif options["direct_link"] == "1" options.delete("direct_link") ibin = Imagebin.new(options) puts ibin.pic_link end