3 ### Pastie from the console (thanks pinupgeek)
5 # file = pastie.rb (depends on pastie_client.rb)
7 require 'pastie_client'
18 :nick => "rubuildius",
23 @parser = OptionParser.new do |cmd|
24 cmd.banner += " <filename>\n\nReads from STDIN if not passed a filename.\n\n"
25 cmd.on('-h', '--help', 'Show usage') { puts parser.help; exit }
26 # cmd.on('-u', '--nick NICK', 'Set nickname') { |n| opt[:nick] = n }
27 # cmd.on('-k', '--key KEY', 'Key to authenticate your nick') { |n| opt[:nick] = n }
28 cmd.on('-l', '--language LANG', 'Set language for syntax highlighting') { |l| opt[:parser] = l }
35 body = File.read(ARGV[0])
39 return if body.strip.empty?
41 p = PastieClient.new( :nick => opt[:nick], :key => opt[:key] )
42 id = p.paste(body, opt[:parser])
43 puts "http://pastie.caboo.se/paste/#{id}"