Sha256: 67cc6faede31e423c72d8ab80ea8f220c4f706758a3a0deb17590cbb834cbcaa
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
#!/usr/bin/env ruby require 'usaidwat' require 'usaidwat/utils' 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 = comments.longest_subreddit.length comments.each { |c| printf "%-*s %s\n", max_key, c.first, c.last } else subreddit = ARGV.shift comments = reddit_user.comments_for_subreddit subreddit unless comments puts "No comments by #{reddit_user.username} for #{subreddit}." exit 0 end is_first = true run_pager 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.5 | bin/usaidwat |