Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

1.2 KB
Raw Blame
import XCLIUtils
import XUtils
import Foundation
import ArgumentParser
import XKit

struct DSTeamsCommand: ParsableCommand {
    static let configuration = CommandConfiguration(
        commandName: "teams",
        abstract: "Interact with development teams",
        subcommands: [
            DSTeamsListCommand.self
        ],
        defaultSubcommand: DSTeamsListCommand.self
    )
}

struct DSTeamsListCommand: AsyncParsableCommand {
    static let configuration = CommandConfiguration(
        commandName: "list",
        abstract: "List teams"
    )

    func run() async throws {
        let token = try AuthToken.saved()

        guard case let .xcode(authData) = token.authData() else {
            throw Console.Error("This command requires password-based authentication")
        }
        let client = DeveloperServicesClient(authData: authData)
        let teams: [DeveloperServicesTeam] = try await client.send(DeveloperServicesListTeamsRequest())
        d.out.print(
            teams.map {
                "\($0.name) [\($0.status)]: \($0.id.rawValue)" +
                    $0.memberships.map { "\n- \($0.name) (\($0.platform))" }.joined()
            }.joined(separator: "\n")
        )
    }
}