Skip to content

Commit

Permalink
Add active players fetching functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusziade committed Oct 29, 2024
1 parent 3e5f2d5 commit ebf7300
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Sources/StarCraftCLI/activePlayers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

func activePlayers() async {
do {
let response = try await api.allPlayers().activePlayers
print("Fetched active players:\n\(response.map(\.name))")
} catch {
print("Failed to fetch active players \(error)")
}
}
2 changes: 2 additions & 0 deletions Sources/StarCraftCLI/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ func main() {

Task.detached(priority: .medium) {
switch command {
case "-ap":
await activePlayers()
case "-ot":
await ongoingTournaments()
case "-ut":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct Player: Codable, Identifiable {
public let lastName: String?
public let modifiedAt: Date
public let name: String
public let nationality: String
public let nationality: String?
public let role: String?
public let slug: String
public let currentVideogame: Videogame?
Expand Down

0 comments on commit ebf7300

Please sign in to comment.