From 0dae8220936a85af08e25261e82e3d0787984d6f Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Tue, 22 Jul 2008 20:03:11 -0400 Subject: [PATCH] Moved CHANGELOG to History.txt. Added descriptions for all the command line modes. Refreshed the manifest of files. Removed the command.rb file as it is no longer needed. Updated the version number. --- CHANGELOG | 53 --------- History.txt | 62 +++++++++- Manifest.txt | 10 +- lib/twitter/cli.rb | 25 +++- lib/twitter/command.rb | 253 ----------------------------------------- lib/twitter/version.rb | 2 +- 6 files changed, 89 insertions(+), 316 deletions(-) delete mode 100644 CHANGELOG delete mode 100644 lib/twitter/command.rb diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 034167248..000000000 --- a/CHANGELOG +++ /dev/null @@ -1,53 +0,0 @@ -0.2.7 - June 29, 2008 - * added #rate_limit_status (Daniel Morrison) - * added source parameter option to Base#post - * added twittergem as source when posting from command line - * Twitter::RateExceeded raised when you hit your limit (Jim O'Leary) - * Twitter::Unavailable raised when twitter returns 503 - * Twitter::CantConnect is now more descriptive as to what is the problem when it is raised during a request - * quoting your message when using twitter post on the command line is now optional (Benoit Caccinolo) - * aliased post to p on command line so it's shorter (Benoit Caccinolo) - * unescaped html and added some color in command line view (Miles Z. Sterrett) - * added gemspec (technoweenie, Miles Z. Sterrett) - * Fixed stack trace error on first command line operation (Matt Rose) -0.2.6 - April 2, 2008 - * found a more simple way of doing stdin without any extra gem dependencies -0.2.5 - April 2, 2008 - * Command line interface can now use stdin for posting (ideas and example code from Jeremy Friesen) - $ twitter post 'test without stdin' # => twitters: test without stdin - $ echo 'test with stdin' | twitter post 'and an argv[1]' # => twitters: test with stdin and an argv[1] - $ echo 'test with stdin without any argv[1]' | twitter post # => twitters: test with stdin without any argv[1] -0.2.4 - Mar 31, 2008 - * Added lite option to friends and followers, which doesn't include the user's current status (Daniel Morrison) - * Updated since option to use HTTP header, and added the option on timeline() and replies(). (Daniel Morrison) -0.2.3 - Jan 16, 2008 - * added d to command line interface twitter d jnunemaker 'hola' (Humbucker) - * added progress dots when posting for confirmation when twitter is running slow (Hendy Irawan) -0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off -0.2.0 - Aug 4, 2007 - * added sent_messages - * alias direct_messages to received_messages - * added create_friendship - * added destroy_friendship - * added featured to retrieve the featured twitter users - * added replies - * added destroy to destroy a status by id - * added status to find a status by id - * added active support as an extra dependency - * implemented d method to send direct messages (jnewland) - * fixed since argument in direct_messages method (jnewland) -0.1.1 - May 20, 2007 - * hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!) -0.1.0 - March 31, 2007 - * added d method for creating direct messages (waiting for it to work as documented) - * added featured method for getting featured users statuses (waiting for it to work as documented) - * added direct_messages method - * added friends_for method - * added a few tests - * removed relative_created_at as it is deprecated - * separated out the call method into call, request and parse methods -0.0.5 - just a bit of code cleanup -0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne) -0.0.3 - added a bit more informative message when things go wrong -0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs -0.0.1 - initial release \ No newline at end of file diff --git a/History.txt b/History.txt index b68f11808..2a1815c7c 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,58 @@ -== 0.0.1 2008-03-12 - -* 1 major enhancement: - * Initial release +0.2.8 - July 22, 2008 + * complete rewrite of CLI. Now supports multiple accounts and changing between them. + * added source, truncated, in_reply_to_status_id, in_reply_to_user_id, and favorited to Twitter::Status + * added protected to Twitter::User + * d CLI method now takes standard input like post +0.2.7 - June 29, 2008 + * added #rate_limit_status (Daniel Morrison) + * added source parameter option to Base#post + * added twittergem as source when posting from command line + * Twitter::RateExceeded raised when you hit your limit (Jim O'Leary) + * Twitter::Unavailable raised when twitter returns 503 + * Twitter::CantConnect is now more descriptive as to what is the problem when it is raised during a request + * quoting your message when using twitter post on the command line is now optional (Benoit Caccinolo) + * aliased post to p on command line so it's shorter (Benoit Caccinolo) + * unescaped html and added some color in command line view (Miles Z. Sterrett) + * added gemspec (technoweenie, Miles Z. Sterrett) + * Fixed stack trace error on first command line operation (Matt Rose) +0.2.6 - April 2, 2008 + * found a more simple way of doing stdin without any extra gem dependencies +0.2.5 - April 2, 2008 + * Command line interface can now use stdin for posting (ideas and example code from Jeremy Friesen) + $ twitter post 'test without stdin' # => twitters: test without stdin + $ echo 'test with stdin' | twitter post 'and an argv[1]' # => twitters: test with stdin and an argv[1] + $ echo 'test with stdin without any argv[1]' | twitter post # => twitters: test with stdin without any argv[1] +0.2.4 - Mar 31, 2008 + * Added lite option to friends and followers, which doesn't include the user's current status (Daniel Morrison) + * Updated since option to use HTTP header, and added the option on timeline() and replies(). (Daniel Morrison) +0.2.3 - Jan 16, 2008 + * added d to command line interface twitter d jnunemaker 'hola' (Humbucker) + * added progress dots when posting for confirmation when twitter is running slow (Hendy Irawan) +0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off +0.2.0 - Aug 4, 2007 + * added sent_messages + * alias direct_messages to received_messages + * added create_friendship + * added destroy_friendship + * added featured to retrieve the featured twitter users + * added replies + * added destroy to destroy a status by id + * added status to find a status by id + * added active support as an extra dependency + * implemented d method to send direct messages (jnewland) + * fixed since argument in direct_messages method (jnewland) +0.1.1 - May 20, 2007 + * hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!) +0.1.0 - March 31, 2007 + * added d method for creating direct messages (waiting for it to work as documented) + * added featured method for getting featured users statuses (waiting for it to work as documented) + * added direct_messages method + * added friends_for method + * added a few tests + * removed relative_created_at as it is deprecated + * separated out the call method into call, request and parse methods +0.0.5 - just a bit of code cleanup +0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne) +0.0.3 - added a bit more informative message when things go wrong +0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs +0.0.1 - initial release \ No newline at end of file diff --git a/Manifest.txt b/Manifest.txt index bef2414d2..07d25375d 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -1,4 +1,3 @@ -CHANGELOG History.txt License.txt Manifest.txt @@ -10,7 +9,14 @@ config/requirements.rb examples/twitter.rb lib/twitter.rb lib/twitter/base.rb -lib/twitter/command.rb +lib/twitter/cli.rb +lib/twitter/cli/config.rb +lib/twitter/cli/helpers.rb +lib/twitter/cli/migrations/20080722194500_create_accounts.rb +lib/twitter/cli/migrations/20080722194508_create_tweets.rb +lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb +lib/twitter/cli/models/account.rb +lib/twitter/cli/models/tweet.rb lib/twitter/direct_message.rb lib/twitter/easy_class_maker.rb lib/twitter/rate_limit_status.rb diff --git a/lib/twitter/cli.rb b/lib/twitter/cli.rb index 5d27c8e80..6cc582a61 100644 --- a/lib/twitter/cli.rb +++ b/lib/twitter/cli.rb @@ -7,22 +7,23 @@ require 'highline/import' require 'activerecord' require 'sqlite3' -HighLine.track_eof = false +HighLine.track_eof = false CLI_ROOT = File.expand_path(File.join(File.dirname(__FILE__), 'cli')) require CLI_ROOT + '/config' require CLI_ROOT + '/helpers' - Dir[CLI_ROOT + '/models/*.rb'].each { |m| require m } include Twitter::CLI::Helpers Main { def run - puts 'This is where the help goes' + puts "twitter [command] --help for usage instructions." + puts "The available commands are: \n install, uninstall, add, remove, list, change, post, befriend, defriend, follow, leave, d and timeline." end mode 'install' do + description 'Creates the sqlite3 database and runs the migrations.' def run migrate say 'Twitter installed.' @@ -30,6 +31,7 @@ def run end mode 'uninstall' do + description 'Removes the sqlite3 database. There is no undo for this.' def run FileUtils.rm(Twitter::CLI::Config[:database]) say 'Twitter gem uninstalled.' @@ -37,6 +39,7 @@ def run end mode 'add' do + description 'Adds a new twitter account to the database. Prompts for username and password.' def run account = Hash.new say "Add New Account:" @@ -60,6 +63,7 @@ def run end mode 'remove' do + description 'Removes a twitter account from the database. If username provided it removes that username else it prompts with list and asks for which one you would like to remove.' argument( 'username' ) { optional description 'username of account you would like to remove' @@ -92,6 +96,7 @@ def run end mode 'list' do + description 'Lists all the accounts that have been added and puts a * by the current one that is used for posting, etc.' def run do_work do if Account.count == 0 @@ -107,6 +112,7 @@ def run end mode 'change' do + description 'Changes the current account being used for posting etc. to the username provided. If no username is provided, a list is presented and you can choose the account from there.' argument( 'username' ) { optional description 'username of account you would like to switched to' @@ -136,6 +142,10 @@ def run end mode 'post' do + description "Posts a message to twitter using the current account. The following are all valid examples from the command line: + $ twitter post 'my update' + $ twitter post my update with quotes + $ echo 'my update from stdin' | twitter post" def run do_work do post = ARGV.size > 1 ? ARGV.join(" ") : ARGV.shift @@ -154,6 +164,7 @@ def run end mode 'befriend' do + description "Allows you to add a user as a friend" argument('username') { required description 'username or id of twitterrer to befriend' @@ -169,6 +180,7 @@ def run end mode 'defriend' do + description "Allows you to remove a user from being a friend" argument('username') { required description 'username or id of twitterrer to defriend' @@ -184,6 +196,7 @@ def run end mode 'follow' do + description "Allows you to turn on notifications for a user" argument('username') { required description 'username or id of twitterrer to follow' @@ -199,6 +212,7 @@ def run end mode 'leave' do + description "Allows you to turn off notifications for a user" argument('username') { required description 'username or id of twitterrer to leave' @@ -214,6 +228,10 @@ def run end mode 'd' do + description "Allows you to direct message a user. The following are all valid examples from the command line: + $ twitter d jnunemaker 'yo homeboy' + $ twitter d jnunemaker yo homeboy + $ echo 'yo homeboy' | twitter d jnunemaker" argument('username') { required description 'username or id of twitterrer to direct message' @@ -230,6 +248,7 @@ def run end mode 'timeline' do + description "Allows you to view your timeline, your friends or the public one" argument( 'timeline' ) { description 'the timeline you wish to see (friends, public, me)' default 'friends' diff --git a/lib/twitter/command.rb b/lib/twitter/command.rb deleted file mode 100644 index c8e773b37..000000000 --- a/lib/twitter/command.rb +++ /dev/null @@ -1,253 +0,0 @@ -# The command class is used for the command line interface. -# It is only used and included in the bin/twitter file. -module Twitter - class Command - @@commands = [:post, :p, :timeline, :friends, :friend, :followers, :follower, :featured, :important, :follow, :leave, :d] - - @@template = < [options]\n\nAvailable Commands:" - Twitter::Command.commands.each do |c| - puts " - #{c}" - end - end - end - - def commands - @@commands - end - - # Posts an updated status to twitter - def post - config = create_or_find_config - - if ARGV.size == 0 - puts %(\n You didn't enter a message to post.\n\n Usage: twitter post "You're fabulous message"\n) - exit(0) - end - - post = if ARGV.size > 1 - ARGV.join " " - else - ARGV.shift - end - - print "\nSending twitter update" - finished = false - status = nil - progress_thread = Thread.new { until finished; print "."; $stdout.flush; sleep 0.5; end; } - post_thread = Thread.new(binding()) { |b| - status = Twitter::Base.new(config['email'], config['password']).post(post, :source => Twitter::SourceName) - finished = true - } - post_thread.join - progress_thread.join - puts " OK!" - puts "Got it! New twitter created at: #{status.created_at}\n" - end - alias :p :post - - # Shows status, time and user for the specified timeline - def timeline - config = create_or_find_config - - timeline = :friends - timeline = ARGV.shift.intern if ARGV.size > 0 && Twitter::Base.timelines.include?(ARGV[0].intern) - - puts - Twitter::Base.new(config['email'], config['password']).timeline(timeline).each do |s| - puts "#{CGI::unescapeHTML(s.text)}\n --\e[34m #{CGI::unescapeHTML(s.user.name)}\e[32m at #{s.created_at}" - puts "\e[0m" - end - end - - def friends - config = create_or_find_config - - puts - Twitter::Base.new(config['email'], config['password']).friends.each do |u| - puts "#{u.name} (#{u.screen_name})" - puts "#{u.status.text} at #{u.status.created_at}" unless u.status.nil? - end - end - - # Shows last updated status and time for a friend - # Needs a screen name - def friend - config = create_or_find_config - - if ARGV.size == 0 - puts %(\n You forgot to enter a screen name.\n\n Usage: twitter friend jnunemaker\n) - exit(0) - end - - screen_name = ARGV.shift - - puts - found = false - Twitter::Base.new(config['email'], config['password']).friends.each do |u| - if u.screen_name == screen_name - puts "#{u.name} #{u.screen_name}" - puts "#{u.status.text} at #{u.status.created_at}" unless u.status.nil? - found = true - end - end - - puts "Sorry couldn't find a friend of yours with #{screen_name} as a screen name" unless found - end - - # Shows all followers and their last updated status - def followers - config = create_or_find_config - - puts - Twitter::Base.new(config['email'], config['password']).followers.each do |u| - puts "#{u.name} (#{u.screen_name})" - puts "#{u.status.text} at #{u.status.created_at}" unless u.status.nil? - end - end - - # Shows last updated status and time for a follower - # Needs a screen name - def follower - config = create_or_find_config - - if ARGV.size == 0 - puts %(\n You forgot to enter a screen name.\n\n Usage: twitter follower jnunemaker\n) - exit(0) - end - - screen_name = ARGV.shift - - puts - found = false - Twitter::Base.new(config['email'], config['password']).followers.each do |u| - if u.screen_name == screen_name - puts "#{u.name} (#{u.screen_name})" - puts "#{u.status.text} at #{u.status.created_at}" unless u.status.nil? - found = true - end - end - - puts "Sorry couldn't find a follower of yours with #{screen_name} as a screen name" unless found - end - - def featured - config = create_or_find_config - - puts - Twitter::Base.new(config['email'], config['password']).featured.each do |u| - puts "#{u.name} last updated #{u.status.created_at}\n-- #{u.status.text}" - puts - end - end - - def important - config = create_or_find_config - - puts - if config['important'].nil? - puts "You have not listed your most important twitter buddies in your config file.\nYou can add important twitterers by adding the following to your config file:\nimportant:\n- jnunemaker\n- frankfurter" - else - Twitter::Base.new(config['email'], config['password']).timeline(:friends).each do |s| - if config['important'].include?(s.user.screen_name) - puts "#{s.text}\n-- #{s.user.name} at #{s.created_at}" - puts - end - end - end - end - - def follow - config = create_or_find_config - - if ARGV.size == 0 - puts %(\n You forgot to enter a screen name or id to follow.\n\n Usage: twitter follow jnunemaker\n) - exit(0) - end - - screen_name = ARGV.shift - - puts - found = false - begin - Twitter::Base.new(config['email'], config['password']).follow(screen_name) - puts "You are now following notifications for #{screen_name}." - rescue - puts "FAIL: Somethin went wrong. Sorry." - end - end - - def leave - config = create_or_find_config - - if ARGV.size == 0 - puts %(\n You forgot to enter a screen name or id to leave.\n\n Usage: twitter leave jnunemaker\n) - exit(0) - end - - screen_name = ARGV.shift - - puts - found = false - begin - Twitter::Base.new(config['email'], config['password']).leave(screen_name) - puts "You are no longer following notifications for #{screen_name}." - rescue - puts "FAIL: Somethin went wrong. Sorry." - end - end - - # Posts a direct message to twitter - def d - config = create_or_find_config - if ARGV.size != 2 - puts %(\n You didn't do it right.\n\n Usage: twitter d jnunemaker "You're fabulous message"\n) - exit(0) - end - - user = ARGV.shift - post = ARGV.shift - - status = Twitter::Base.new(config['email'], config['password']).d(user, post) - puts "\nDirect message sent to #{user}.\n" - end - - private - # Checks for the config, creates it if not found - def create_or_find_config - home = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] - begin - config = YAML::load open(home + "/.twitter") - rescue - open(home + '/.twitter','w').write(@@template) - config = YAML::load(@@template) - end - - if config['email'] == nil or config['password'] == nil - puts "Please edit ~/.twitter to include your twitter email and password\nTextmate users: mate ~/.twitter" - exit(0) - end - - config - end - end - end -end \ No newline at end of file diff --git a/lib/twitter/version.rb b/lib/twitter/version.rb index 91910b921..68fec9d42 100644 --- a/lib/twitter/version.rb +++ b/lib/twitter/version.rb @@ -2,7 +2,7 @@ module Twitter #:nodoc: module VERSION #:nodoc: MAJOR = 0 MINOR = 2 - TINY = 7 + TINY = 8 STRING = [MAJOR, MINOR, TINY].join('.') end