def find_team(name, options={})
matching_teams = if options[:global]
search_teams(name, true).select { |t| t.name == name }
elsif options[:owned]
owned_teams.select { |t| t.name == name }
else
teams.select{ |t| t.name == name }
end
if matching_teams.blank?
raise TeamNotFoundException.new("Team with name #{name} not found")
elsif matching_teams.length > 1
raise TeamNotFoundException.new("Multiple teams with name #{name} found. Use --team-id to select the team by id.")
else
matching_teams.first
end
end