lib/augury/cli.rb in augury-0.2.1 vs lib/augury/cli.rb in augury-0.3.0

- old
+ new

@@ -2,26 +2,34 @@ require 'augury' module Augury class CLI < Thor desc 'generate USERNAME [PATH]', 'Generate a fortune file for the given username' - option :width, :type => :numeric, :aliases => :w - option :append, :type => :boolean, :aliases => :a + option :width, + :type => :numeric, :aliases => '-w', + :desc => 'The maximum number of columns that will be written on a line. DEFAULT: 72' + option :append, + :type => :boolean, :aliases => '-a', + :desc => 'If set, the target path will be appended to instead of overwritten' + option :count, + :type => :numeric, :aliases => '-c', + :desc => 'The number of tweets to get. Set to 0 to get all. DEFAULT: 200' def generate(username, *path) - path = File.expand_path(path[0] || username) begin - augury = Augury::Fortune.new( - username, - path, - options['width'], - options['append'] - ) - rescue Augury::TwitterConfigError => e - puts e.message + path = File.expand_path(path[0] || username) + augury = Augury::Fortune.new( + username, + path, + options['width'], + options['append'], + options['count'], + ) + augury.write_fortune + self.say "Fortune written out to #{path}" + rescue => e + self.say "There was an error running the command. Details below:" + self.say e.message exit 1 end - tweets = augury.tweet_texts - augury.write_fortune(augury.format_fortune(tweets)) - puts "Fortune written out to #{path}" end end end