Skip to content

Commit ea98a31

Browse files
authored
Code and documentation cleanup (#256)
Omit internal access control, if let shorthand, fix typos.
1 parent f8a8dd4 commit ea98a31

File tree

22 files changed

+76
-79
lines changed

22 files changed

+76
-79
lines changed

DESIGN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ To use the latest installed main snapshot, leave off the date:
223223

224224
`swiftly use main-snapshot`
225225

226-
The use subcommand also supports `.swift-version` files. If a ".swift-version" file is present in the current working directory, or an ancestory directory, then swiftly will update that file with the new version to use. This can be a useful feature for a team to share and align on toolchain versions with git. As a special case, if swiftly could not find a version file, but it could find a Package.swift file it will create a new version file for you in the package and set that to the requested toolchain version.
226+
The use subcommand also supports `.swift-version` files. If a ".swift-version" file is present in the current working directory, or an ancestry directory, then swiftly will update that file with the new version to use. This can be a useful feature for a team to share and align on toolchain versions with git. As a special case, if swiftly could not find a version file, but it could find a Package.swift file it will create a new version file for you in the package and set that to the requested toolchain version.
227227

228228
Note: The `.swift-version` file mechanisms can be overridden using the `--global-default` flag so that your swiftly installation's default toolchain can be set explicitly.
229229

Documentation/SwiftlyDocs.docc/automated-install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To begin using installed swiftly from your current shell, first run the followin
3434
. "/root/.local/share/swiftly/env.sh"
3535
```
3636

37-
> Note: on macOS systems you may need to run 'hash -r' to recalcuate the zsh PATH cache when installing swiftly and toolchains.
37+
> Note: on macOS systems you may need to run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains.
3838
3939
You can go ahead and add this command to the list of commands in your build script so that the build can proceed to call swiftly from the path. The usual next step is to install a specific swift toolchain like this:
4040

Documentation/SwiftlyDocs.docc/swiftly-cli-reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Likewise, the available toolchains associated with a given minor version can be
123123

124124
$ swiftly list-available 5.2
125125

126-
The installed snapshots for a given devlopment branch can be listed by specifying the branch as the selector:
126+
The installed snapshots for a given development branch can be listed by specifying the branch as the selector:
127127

128128
$ swiftly list-available main-snapshot
129129
$ swiftly list-available x.y-snapshot
@@ -301,7 +301,7 @@ Likewise, the installed toolchains associated with a given minor version can be
301301

302302
$ swiftly list 5.2
303303

304-
The installed snapshots for a given devlopment branch can be listed by specifying the branch as the selector:
304+
The installed snapshots for a given development branch can be listed by specifying the branch as the selector:
305305

306306
$ swiftly list main-snapshot
307307
$ swiftly list 5.7-snapshot
@@ -522,7 +522,7 @@ If the command that you are running needs the arguments with the '+' prefixes th
522522

523523
$ swiftly run ./myscript.sh ++abcde
524524

525-
The script will receive the argument as '+abcde'. If there are multiple arguments with the '+' prefix that should be escaped you can disable the selection using a '++' argument, which turns off any selector argument processing for subsequent arguments. This is anologous to the '--' that turns off flag and option processing for subsequent arguments in many argument parsers.
525+
The script will receive the argument as '+abcde'. If there are multiple arguments with the '+' prefix that should be escaped you can disable the selection using a '++' argument, which turns off any selector argument processing for subsequent arguments. This is analogous to the '--' that turns off flag and option processing for subsequent arguments in many argument parsers.
526526

527527
$ swiftly run ./myscript.sh ++ +abcde +xyz
528528

Documentation/SwiftlyDocs.docc/uninstall-toolchains.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If you have a released version that you want to uninstall then give the exact th
1010
$ swiftly uninstall 5.6.1
1111
```
1212

13-
When you're done working with every patch of a minor swift release you can remove them all by omiting the patch version.
13+
When you're done working with every patch of a minor swift release you can remove them all by omitting the patch version.
1414

1515
```
1616
$ swiftly uninstall 5.6

Sources/LinuxPlatform/Extract.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func copyData(readArchive: OpaquePointer?, writeArchive: OpaquePointer?) throws
4444
/// the provided closure which will return the path the file will be written to.
4545
///
4646
/// This uses libarchive under the hood, so a wide variety of archive formats are supported (e.g. .tar.gz).
47-
internal func extractArchive(atPath archivePath: URL, transform: (String) -> URL) throws {
47+
func extractArchive(atPath archivePath: URL, transform: (String) -> URL) throws {
4848
var flags = Int32(0)
4949
flags = ARCHIVE_EXTRACT_TIME
5050
flags |= ARCHIVE_EXTRACT_PERM

Sources/LinuxPlatform/Linux.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public struct Linux: Platform {
248248
if requireSignatureValidation {
249249
guard (try? self.runProgram("gpg", "--version", quiet: true)) != nil else {
250250
var msg = "gpg is not installed. "
251-
if let manager = manager {
251+
if let manager {
252252
msg += """
253253
You can install it by running this command as root:
254254
\(manager) -y install gpg
@@ -416,7 +416,7 @@ public struct Linux: Platform {
416416
}
417417

418418
private func manualSelectPlatform(_ platformPretty: String?) async -> PlatformDefinition {
419-
if let platformPretty = platformPretty {
419+
if let platformPretty {
420420
print("\(platformPretty) is not an officially supported platform, but the toolchains for another platform may still work on it.")
421421
} else {
422422
print("This platform could not be detected, but a toolchain for one of the supported platforms may work on it.")

Sources/Swiftly/Config.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public struct Config: Codable, Equatable {
1111
public var platform: PlatformDefinition
1212
public var version: SwiftlyVersion?
1313

14-
internal init(inUse: ToolchainVersion?, installedToolchains: Set<ToolchainVersion>, platform: PlatformDefinition) {
14+
init(inUse: ToolchainVersion?, installedToolchains: Set<ToolchainVersion>, platform: PlatformDefinition) {
1515
self.inUse = inUse
1616
self.installedToolchains = installedToolchains
1717
self.platform = platform

Sources/Swiftly/Init.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ArgumentParser
22
import Foundation
33
import SwiftlyCore
44

5-
internal struct Init: SwiftlyCommand {
5+
struct Init: SwiftlyCommand {
66
public static var configuration = CommandConfiguration(
77
abstract: "Perform swiftly initialization into your user account."
88
)
@@ -29,12 +29,12 @@ internal struct Init: SwiftlyCommand {
2929

3030
public mutating func validate() throws {}
3131

32-
internal mutating func run() async throws {
32+
mutating func run() async throws {
3333
try await Self.execute(assumeYes: self.root.assumeYes, noModifyProfile: self.noModifyProfile, overwrite: self.overwrite, platform: self.platform, verbose: self.root.verbose, skipInstall: self.skipInstall, quietShellFollowup: self.quietShellFollowup)
3434
}
3535

3636
/// Initialize the installation of swiftly.
37-
internal static func execute(assumeYes: Bool, noModifyProfile: Bool, overwrite: Bool, platform: String?, verbose: Bool, skipInstall: Bool, quietShellFollowup: Bool) async throws {
37+
static func execute(assumeYes: Bool, noModifyProfile: Bool, overwrite: Bool, platform: String?, verbose: Bool, skipInstall: Bool, quietShellFollowup: Bool) async throws {
3838
try Swiftly.currentPlatform.verifySwiftlySystemPrerequisites()
3939

4040
var config = try? Config.load()

Sources/Swiftly/List.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ struct List: SwiftlyCommand {
2525
2626
$ swiftly list 5.2
2727
28-
The installed snapshots for a given devlopment branch can be listed by specifying the branch as the selector:
28+
The installed snapshots for a given development branch can be listed by specifying the branch as the selector:
2929
3030
$ swiftly list main-snapshot
3131
$ swiftly list 5.7-snapshot
3232
"""
3333
))
3434
var toolchainSelector: String?
3535

36-
internal mutating func run() async throws {
36+
mutating func run() async throws {
3737
try validateSwiftly()
3838
let selector = try self.toolchainSelector.map { input in
3939
try ToolchainSelector(parsing: input)
@@ -46,7 +46,7 @@ struct List: SwiftlyCommand {
4646

4747
let printToolchain = { (toolchain: ToolchainVersion) in
4848
var message = "\(toolchain)"
49-
if let inUse = inUse, toolchain == inUse {
49+
if let inUse, toolchain == inUse {
5050
message += " (in use)"
5151
}
5252
if toolchain == config.inUse {
@@ -56,20 +56,19 @@ struct List: SwiftlyCommand {
5656
}
5757

5858
if let selector {
59-
let modifier: String
60-
switch selector {
59+
let modifier = switch selector {
6160
case let .stable(major, minor, nil):
6261
if let minor {
63-
modifier = "Swift \(major).\(minor) release"
62+
"Swift \(major).\(minor) release"
6463
} else {
65-
modifier = "Swift \(major) release"
64+
"Swift \(major) release"
6665
}
6766
case .snapshot(.main, nil):
68-
modifier = "main development snapshot"
67+
"main development snapshot"
6968
case let .snapshot(.release(major, minor), nil):
70-
modifier = "\(major).\(minor) development snapshot"
69+
"\(major).\(minor) development snapshot"
7170
default:
72-
modifier = "matching"
71+
"matching"
7372
}
7473

7574
let message = "Installed \(modifier) toolchains"

Sources/Swiftly/ListAvailable.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct ListAvailable: SwiftlyCommand {
2525
2626
$ swiftly list-available 5.2
2727
28-
The installed snapshots for a given devlopment branch can be listed by specifying the branch as the selector:
28+
The installed snapshots for a given development branch can be listed by specifying the branch as the selector:
2929
3030
$ swiftly list-available main-snapshot
3131
$ swiftly list-available x.y-snapshot
@@ -39,7 +39,7 @@ struct ListAvailable: SwiftlyCommand {
3939
case toolchainSelector
4040
}
4141

42-
internal mutating func run() async throws {
42+
mutating func run() async throws {
4343
try validateSwiftly()
4444
let selector = try self.toolchainSelector.map { input in
4545
try ToolchainSelector(parsing: input)
@@ -80,20 +80,19 @@ struct ListAvailable: SwiftlyCommand {
8080
}
8181

8282
if let selector {
83-
let modifier: String
84-
switch selector {
83+
let modifier = switch selector {
8584
case let .stable(major, minor, nil):
8685
if let minor {
87-
modifier = "Swift \(major).\(minor) release"
86+
"Swift \(major).\(minor) release"
8887
} else {
89-
modifier = "Swift \(major) release"
88+
"Swift \(major) release"
9089
}
9190
case .snapshot(.main, nil):
92-
modifier = "main development snapshot"
91+
"main development snapshot"
9392
case let .snapshot(.release(major, minor), nil):
94-
modifier = "\(major).\(minor) development snapshot"
93+
"\(major).\(minor) development snapshot"
9594
default:
96-
modifier = "matching"
95+
"matching"
9796
}
9897

9998
let message = "Available \(modifier) toolchains"

0 commit comments

Comments
 (0)