Sha256: 8f64c937144f84558ffc271b94e84a9ce4c5b788686e8c8f713d78d4801a23a0
Contents?: true
Size: 963 Bytes
Versions: 1
Compression:
Stored size: 963 Bytes
Contents
#!/usr/bin/env ruby require 'usaidwat' VERSION = "usaidwat v#{USaidWat::VERSION}" USAGE = "Usage: #{File.basename $0} <user> [<subreddit>]" def die(code=1) $stderr.puts VERSION $stderr.puts USAGE exit code end die if ARGV.length < 1 or ARGV.length > 2 if ARGV.first == '--help' or ARGV.first == '-h' puts USAGE exit 0 end if ARGV.first == '--version' or ARGV.first == '-V' puts VERSION exit 0 end reddit_user = USaidWat::RedditUser.new ARGV.shift if ARGV.length == 0 comments = reddit_user.retrieve_comments exit 2 unless comments max_key = 1 comments.each { |c| max_key = c.first.length if c.first.length > max_key } comments.each { |c| printf "%-*s %s\n", max_key, c.first, c.last } else subreddit = ARGV.shift comments = reddit_user.comments_for_subreddit subreddit is_first = true width = `tput cols`.to_i rescue 80 comments.each do |c| puts '-' * width unless is_first puts c is_first = false end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
usaidwat-0.0.3 | bin/usaidwat |