def select_team(team_id: nil, team_name: nil)
      t_id = (team_id || ENV['FASTLANE_ITC_TEAM_ID'] || '').strip
      t_name = (team_name || ENV['FASTLANE_ITC_TEAM_NAME'] || '').strip

      if t_name.length > 0 && t_id.length.zero? # we prefer IDs over names, they are unique
        puts("Looking for App Store Connect Team with name #{t_name}") if Spaceship::Globals.verbose?

        teams.each do |t|
          t_id = t['contentProvider']['contentProviderId'].to_s if t['contentProvider']['name'].casecmp(t_name).zero?
        end

        puts("Could not find team with name '#{t_name}', trying to fallback to default team") if t_id.length.zero?
      end

      t_id = teams.first['contentProvider']['contentProviderId'].to_s if teams.count == 1

      if t_id.length > 0
        puts("Looking for App Store Connect Team with ID #{t_id}") if Spaceship::Globals.verbose?

        # actually set the team id here
        self.team_id = t_id
        return self.team_id
      end

      # user didn't specify a team... #thisiswhywecanthavenicethings
      loop do
        puts("Multiple #{'App Store Connect teams'.yellow} found, please enter the number of the team you want to use: ")
        if ENV["FASTLANE_HIDE_TEAM_INFORMATION"].to_s.length == 0
          puts("Note: to automatically choose the team, provide either the App Store Connect Team ID, or the Team Name in your fastlane/Appfile:")
          puts("Alternatively you can pass the team name or team ID using the `FASTLANE_ITC_TEAM_ID` or `FASTLANE_ITC_TEAM_NAME` environment variable")
          first_team = teams.first["contentProvider"]
          puts("")
          puts("  itc_team_id \"#{first_team['contentProviderId']}\"")
          puts("")
          puts("or")
          puts("")
          puts("  itc_team_name \"#{first_team['name']}\"")
          puts("")
        end

        # We're not using highline here, as spaceship doesn't have a dependency to fastlane_core or highline
        teams.each_with_index do |team, i|
          puts("#{i + 1}) \"#{team['contentProvider']['name']}\" (#{team['contentProvider']['contentProviderId']})")
        end

        unless Spaceship::Client::UserInterface.interactive?
          puts("Multiple teams found on App Store Connect, Your Terminal is running in non-interactive mode! Cannot continue from here.")
          puts("Please check that you set FASTLANE_ITC_TEAM_ID or FASTLANE_ITC_TEAM_NAME to the right value.")
          raise "Multiple App Store Connect Teams found; unable to choose, terminal not interactive!"
        end

        selected = ($stdin.gets || '').strip.to_i - 1
        team_to_use = teams[selected] if selected >= 0

        if team_to_use
          self.team_id = team_to_use['contentProvider']['contentProviderId'].to_s # actually set the team id here
          return self.team_id
        end
      end
    end
def select_team(team_id: nil, team_name: nil)
      t_id = (team_id || ENV['FASTLANE_ITC_TEAM_ID'] || '').strip
      t_name = (team_name || ENV['FASTLANE_ITC_TEAM_NAME'] || '').strip

      if t_name.length > 0 && t_id.length.zero? # we prefer IDs over names, they are unique
        puts("Looking for App Store Connect Team with name #{t_name}") if Spaceship::Globals.verbose?

        teams.each do |t|
          t_id = t['contentProvider']['contentProviderId'].to_s if t['contentProvider']['name'].casecmp(t_name).zero?
        end

        puts("Could not find team with name '#{t_name}', trying to fallback to default team") if t_id.length.zero?
      end

      t_id = teams.first['contentProvider']['contentProviderId'].to_s if teams.count == 1

      if t_id.length > 0
        puts("Looking for App Store Connect Team with ID #{t_id}") if Spaceship::Globals.verbose?

        # actually set the team id here
        self.team_id = t_id
        return self.team_id
      end

      # user didn't specify a team... #thisiswhywecanthavenicethings
      loop do
        puts("Multiple #{'App Store Connect teams'.yellow} found, please enter the number of the team you want to use: ")
        if ENV["FASTLANE_HIDE_TEAM_INFORMATION"].to_s.length == 0
          puts("Note: to automatically choose the team, provide either the App Store Connect Team ID, or the Team Name in your fastlane/Appfile:")
          puts("Alternatively you can pass the team name or team ID using the `FASTLANE_ITC_TEAM_ID` or `FASTLANE_ITC_TEAM_NAME` environment variable")
          first_team = teams.first["contentProvider"]
          puts("")
          puts("  itc_team_id \"#{first_team['contentProviderId']}\"")
          puts("")
          puts("or")
          puts("")
          puts("  itc_team_name \"#{first_team['name']}\"")
          puts("")
        end

        # We're not using highline here, as spaceship doesn't have a dependency to fastlane_core or highline
        teams.each_with_index do |team, i|
          puts("#{i + 1}) \"#{team['contentProvider']['name']}\" (#{team['contentProvider']['contentProviderId']})")
        end

        unless Spaceship::Client::UserInterface.interactive?
          puts("Multiple teams found on App Store Connect, Your Terminal is running in non-interactive mode! Cannot continue from here.")
          puts("Please check that you set FASTLANE_ITC_TEAM_ID or FASTLANE_ITC_TEAM_NAME to the right value.")
          raise "Multiple App Store Connect Teams found; unable to choose, terminal not interactive!"
        end

        selected = ($stdin.gets || '').strip.to_i - 1
        team_to_use = teams[selected] if selected >= 0

        if team_to_use
          self.team_id = team_to_use['contentProvider']['contentProviderId'].to_s # actually set the team id here
          return self.team_id
        end
      end
    end
Shows a team selection for the user in the terminal. This should not be
 called on CI systems

 @param team_id (String) (optional): The ID of an App Store Connect team
 @param team_name (String) (optional): The name of an App Store Connect team