Skip to content

Commit 88f19db

Browse files
committed
Remove access to incomplete commands
This temporarily removes the update and self-update commands because they are only partially implemented and are untested. It also updates the list-available command to be clear that it doesn't currently support listing available snapshots.
1 parent bb4b350 commit 88f19db

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

Sources/Swiftly/ListAvailable.swift

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct ListAvailable: SwiftlyCommand {
2929
3030
$ swiftly list-available main-snapshot
3131
$ swiftly list-available 5.7-snapshot
32+
33+
Note that listing available snapshots is currently unsupported. It will be introduced in a future release.
3234
"""
3335
))
3436
var toolchainSelector: String?
@@ -38,6 +40,13 @@ struct ListAvailable: SwiftlyCommand {
3840
try ToolchainSelector(parsing: input)
3941
}
4042

43+
if let selector {
44+
guard !selector.isSnapshotSelector() else {
45+
SwiftlyCore.print("Listing available snapshots is not currently supported.")
46+
return
47+
}
48+
}
49+
4150
let toolchains = try await HTTP.getReleaseToolchains()
4251
.map(ToolchainVersion.stable)
4352
.filter { selector?.matches(toolchain: $0) ?? true }
@@ -54,7 +63,7 @@ struct ListAvailable: SwiftlyCommand {
5463
} else if installedToolchains.contains(toolchain) {
5564
message += " (installed)"
5665
}
57-
print(message)
66+
SwiftlyCore.print(message)
5867
}
5968

6069
if let selector {
@@ -74,25 +83,25 @@ struct ListAvailable: SwiftlyCommand {
7483
modifier = "matching"
7584
}
7685

77-
let message = "available \(modifier) toolchains"
78-
print(message)
79-
print(String(repeating: "-", count: message.utf8.count))
86+
let message = "Available \(modifier) toolchains"
87+
SwiftlyCore.print(message)
88+
SwiftlyCore.print(String(repeating: "-", count: message.utf8.count))
8089
for toolchain in toolchains {
8190
printToolchain(toolchain)
8291
}
8392
} else {
84-
print("available release toolchains")
93+
print("Available release toolchains")
8594
print("----------------------------")
8695
for toolchain in toolchains where toolchain.isStableRelease() {
8796
printToolchain(toolchain)
8897
}
8998

90-
print("")
91-
print("available snapshot toolchains")
92-
print("-----------------------------")
93-
for toolchain in toolchains where toolchain.isSnapshot() {
94-
printToolchain(toolchain)
95-
}
99+
// print("")
100+
// print("Available snapshot toolchains")
101+
// print("-----------------------------")
102+
// for toolchain in toolchains where toolchain.isSnapshot() {
103+
// printToolchain(toolchain)
104+
// }
96105
}
97106
}
98107
}

Sources/Swiftly/Swiftly.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ public struct Swiftly: SwiftlyCommand {
1717
Install.self,
1818
Use.self,
1919
Uninstall.self,
20-
Update.self,
2120
List.self,
2221
ListAvailable.self,
23-
SelfUpdate.self,
2422
]
2523
)
2624

Sources/SwiftlyCore/HTTPClient+GitHubAPI.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ extension HTTP {
5959
/// The results are returned in lexicographic order.
6060
internal static func getReleases(page: Int, perPage: Int = 100) async throws -> [GitHubTag] {
6161
let url = "https://api.github.com/repos/apple/swift/releases?per_page=\(perPage)&page=\(page)"
62-
return try await Self.getFromGitHub(url: url)
62+
let releases: [GitHubRelease] = try await Self.getFromGitHub(url: url)
63+
return releases.filter { !$0.prerelease }.map { $0.toGitHubTag() }
6364
}
6465

6566
/// Get a list of tags on the apple/swift GitHub repository.
@@ -72,6 +73,17 @@ extension HTTP {
7273
}
7374
}
7475

76+
/// Model of a GitHub REST API release object.
77+
/// See: https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#list-releases
78+
private struct GitHubRelease: Decodable {
79+
fileprivate let name: String
80+
fileprivate let prerelease: Bool
81+
82+
fileprivate func toGitHubTag() -> GitHubTag {
83+
GitHubTag(name: self.name, commit: nil)
84+
}
85+
}
86+
7587
/// Model of a GitHub REST API tag/release object.
7688
internal struct GitHubTag: Decodable {
7789
internal struct Commit: Decodable {

0 commit comments

Comments
 (0)