Sha256: 250e593986e068e7df3618ddf87696637204d42fe2bbd6dcbfc78f175c7465be

Contents?: true

Size: 648 Bytes

Versions: 11

Compression:

Stored size: 648 Bytes

Contents

#!/usr/bin/env ruby

require "rubygems"
require "shorturl"

def usage
  puts "Usage: #$0 <url> [<service>]"
  puts "Available services:"
  ShortURL.valid_services.each { |s| puts "\t#{s}" }
  exit(-1)
end

def main
  if ARGV.size < 1
    usage
  end

  url = ARGV[0]
  service = ARGV[1]

  shorturl = if service.nil?
               ShortURL.shorten(url)
             else
               if ShortURL.valid_services.include?(service.to_sym)
                 ShortURL.shorten(url, service.to_sym)
               else
                 puts "Invalid service"
                 exit(-1)
               end
             end

  puts shorturl
    
end

main

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
caleb-shorturl-0.8.5 bin/shorturl
caleb-shorturl-0.8.7 bin/shorturl
caleb-shorturl-0.8.9 bin/shorturl
shorturl-1.0.0 bin/shorturl
shorturl-0.8.8 bin/shorturl
shorturl-0.8.7 bin/shorturl
shorturl-0.8.6 bin/shorturl
shorturl-0.7.0 bin/shorturl
shorturl-0.6.0 bin/shorturl
shorturl-0.5.0 bin/shorturl
shorturl-0.8.4 bin/shorturl