Skip to content

Partial warning cleanup: remove unused awaits and refactor argument parsing #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/MacOSPlatform/MacOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public struct MacOS: Platform {

if ctx.mockedHomeDir == nil {
await ctx.message("Extracting the swiftly package...")
try await sys.installer(
_ = sys.installer(
.pkg(archive),
.target("CurrentUserHomeDirectory")
)
Expand Down Expand Up @@ -193,7 +193,7 @@ public struct MacOS: Platform {
}

public func getShell() async throws -> String {
for (key, value) in try await sys.dscl(datasource: ".").read(path: fs.home, key: ["UserShell"]).properties(self) {
for (_, value) in try await sys.dscl(datasource: ".").read(path: fs.home, key: ["UserShell"]).properties(self) {
return value
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftlyCore/ModeledCommandLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ extension Runnable {
newEnv = newValue
}

try await p.runProgram([executable] + args, quiet: quiet, env: newEnv)
try p.runProgram([executable] + args, quiet: quiet, env: newEnv)
}
}

Expand Down
16 changes: 7 additions & 9 deletions Tools/generate-command-models/GenerateCommandModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct GenerateCommandModels: AsyncParsableCommand {
"""
}

try await allCmds.write(to: URL(fileURLWithPath: self.outputFile), atomically: true, encoding: .utf8)
try allCmds.write(to: URL(fileURLWithPath: self.outputFile), atomically: true, encoding: .utf8)
}

struct Vars {
Expand Down Expand Up @@ -176,14 +176,12 @@ struct GenerateCommandModels: AsyncParsableCommand {

private func argSwitchCase(_ arg: ArgumentInfoV0) -> String {
let flag = arg.kind == .flag
var name: String?
if let longName = arg.names?.filter { $0.kind == .long }.first?.name {
name = "--" + longName
} else if let shortName = arg.names?.filter { $0.kind == .short }.first?.name {
name = "-" + shortName
} else if let longNameWithSingleDash = arg.names?.filter { $0.kind == .longWithSingleDash }.first?.name {
name = "-" + longNameWithSingleDash
}
let name: String? = arg.names?.compactMap { name in
switch name.kind {
case .long: return "--" + name.name
case .short, .longWithSingleDash: return "-" + name.name
}
}.first

guard let name else { fatalError("Unable to find a suitable argument name for \(arg)") }

Expand Down