require 'thor' 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', :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) begin 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 end end end