Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
main ▾

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

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