Sha256: 4260f8a5b026ac2dfee0d4308154779de2d0a9a549b5b4e5791ae8ff9d76ecf7

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 Bytes

Contents

module Bbiff

class Show
  class UsageError < StandardError
  end

  NOTIFY_SEND = 'notify-send'

  def usage
    STDERR.puts 'Usage: bbiff-show TITLE RES_LINE'
  end

  def main
    if ARGV.size != 2
      raise UsageError
    end

    title = ARGV[0]
    post = Bbs::Post.from_line(ARGV[1])
    notify_send = ENV['BBIFF_NOTIFY_SEND'] || 
                  (`which #{NOTIFY_SEND}` != "" ? NOTIFY_SEND : 'echo')
    system("#{notify_send} #{Shellwords.escape(title)} #{Shellwords.escape(render_post(post))}")
    
  rescue UsageError
    usage
  end

end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bbiff-0.2.2 lib/bbiff/show.rb
bbiff-0.2.1 lib/bbiff/show.rb
bbiff-0.2.0 lib/bbiff/show.rb