Skip to content
Browse files

Set the first account as active if removing and there are no active a…

…ccounts
  • Loading branch information...
1 parent dbc9e57 commit 8cfec0f73aedfd7b6718127fae889bba7cec195d @jnunemaker jnunemaker committed Jul 26, 2008
Showing with 7 additions and 1 deletion.
  1. +2 −0 History.txt
  2. +0 −1 TODO.txt
  3. +1 −0 lib/twitter/cli.rb
  4. +4 −0 lib/twitter/cli/models/account.rb
View
2 History.txt
@@ -1,5 +1,7 @@
0.3.2 - July 26, 2008
* added the CLI gems as dependencies for now until I separate out the CLI from the API wrapper
+ * cleaner CLI errors for no active account or no accounts at all
+ * remove sets a new active account if there are none
0.3.1 - July 23, 2008
View
1 TODO.txt
@@ -1,4 +1,3 @@
-* if removing the current account, set a new one
* import from .twitter
* add timeout so it doesn't hang forever like it does now if twitter is down
* add progress indicator for timeline and replies as posting has for more visual indication that work is happening
View
1 lib/twitter/cli.rb
@@ -86,6 +86,7 @@ def run
account = account_id ? Account.find(account_id) : account
account_name = account.username
account.destroy
+ Account.set_current(Account.first) if Account.new_active_needed?
say "#{account_name} has been removed.\n"
rescue ActiveRecord::RecordNotFound
say "ERROR: Account could not be found. Try again. \n"
View
4 lib/twitter/cli/models/account.rb
@@ -14,6 +14,10 @@ def self.set_current(account_or_id)
account
end
+ def self.new_active_needed?
+ self.current.count == 0 && self.count > 0
+ end
+
def to_s
"#{current? ? '*' : ' '} #{username}"
end

0 comments on commit 8cfec0f

Please sign in to comment.
Something went wrong with that request. Please try again.