bin/imagebin in dougsko-imagebin-0.2.3 vs bin/imagebin in dougsko-imagebin-0.3.0

- old
+ new

@@ -26,10 +26,11 @@ 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 <pic.png>" @@ -55,19 +56,26 @@ 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) -File.open(options["f"]) do |file| - options["f"] = file - Imagebin.new(options) do |link| - puts link - end +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