def run
do_work do
if params['username'].given?
account = Account.find_by_username(params['username'].value)
else
Account.find(:all, :order => 'username').each do |a|
say "#{a.id}. #{a}"
end
account_id = ask 'Account to remove (enter number): ' do |q|
q.validate = /\d+/
end
end
begin
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"
end
end
end