Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
appstore-distribution ▾

xtool.git / Sources / XToolSupport / DSCommands / DSTeamsCommand.swift

DSTeamsCommand.swift37 lines · 1.2 KiBRaw
1import Foundation
2import ArgumentParser
3import XKit
4
5struct DSTeamsCommand: ParsableCommand {
6 static let configuration = CommandConfiguration(
7 commandName: "teams",
8 abstract: "Interact with development teams",
9 subcommands: [
10 DSTeamsListCommand.self
11 ],
12 defaultSubcommand: DSTeamsListCommand.self
13 )
14}
15
16struct DSTeamsListCommand: AsyncParsableCommand {
17 static let configuration = CommandConfiguration(
18 commandName: "list",
19 abstract: "List teams"
20 )
21
22 func run() async throws {
23 let token = try AuthToken.saved()
24
25 guard case let .xcode(authData) = token.authData() else {
26 throw Console.Error("This command requires password-based authentication")
27 }
28 let client = DeveloperServicesClient(authData: authData)
29 let teams: [DeveloperServicesTeam] = try await client.send(DeveloperServicesListTeamsRequest())
30 print(
31 teams.map {
32 "\($0.name) [\($0.status)]: \($0.id.rawValue)" +
33 $0.memberships.map { "\n- \($0.name) (\($0.platform))" }.joined()
34 }.joined(separator: "\n")
35 )
36 }
37}