From: Dave Burt Date: 2006-05-01T01:32:20+09:00 Subject: [SOLUTION] Re: [QUIZ] cat2rafb (#77) http://dave.burt.id.au/ruby/nopaste.rb # nopaste.rb - a command-line interface to http://rafb.net/paste # Usage: nopaste.rb [options] # Options: # -l, --lang LANGUAGE Language of snippet (default Plain Text) # C89, C, C++, C#, Java, Pascal, Perl, PHP, # PL/I, Python, Ruby, SQL, VB, Plain Text # -n, --nick NICKNAME Your nickname (9 char max) # -d, --desc DESCRIPTION Description of the snippet (50 char max) # -t, --cvt-tabs [SPACES] Convert tabs to spaces (default No) # No, 2, 3, 4, 5, 6, 7, 8 # -u, --rubyurl Shorten the URL using rubyurl.com # -a, --agree-to-terms Agree to the Terms of Use (mandatory) # -s, --show-terms Show the Terms of Use # -h, --help Show this message D:\Docs\ruby>nopaste.rb -aulR -n"Dave Burt" #!ruby puts "hello world" ^Z Your snippet has been uploaded: http://rubyurl.com/i6U This program should also be usable as a library; in particular, NoPaste.paste(text, options) and RubyUrl.shorten(url). The command-line code is just this: opts = NoPaste.options # process ARGV url = NoPaste.paste(ARGF.read, opts) url = RubyUrl.shorten(url) if opts[:rubyurl] puts "Your snippet has been uploaded:\n #{url}" Cheers, Dave