Skip to content

Consistency in y/n prompts #141 fix #222

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

Merged
merged 4 commits into from
Feb 11, 2025
Merged
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
15 changes: 8 additions & 7 deletions Sources/Swiftly/Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ internal struct Init: SwiftlyCommand {
These locations can be changed with SWIFTLY_HOME and SWIFTLY_BIN environment variables and run this again.
\(installMsg)
""")

if SwiftlyCore.readLine(prompt: "Proceed with the installation? [Y/n] ") == "n" {
guard SwiftlyCore.promptForConfirmation(defaultBehavior: true) else {
throw SwiftlyError(message: "Swiftly installation has been cancelled")
}
}
Expand All @@ -93,9 +92,7 @@ internal struct Init: SwiftlyCommand {
SwiftlyCore.print(" \(swiftlyBinDir.appendingPathComponent(executable).path)")
}

let proceed = SwiftlyCore.readLine(prompt: "Proceed? [y/N]") ?? "n"

guard proceed == "y" else {
guard SwiftlyCore.promptForConfirmation(defaultBehavior: false) else {
throw SwiftlyError(message: "Swiftly installation has been cancelled")
}
}
Expand Down Expand Up @@ -203,8 +200,12 @@ internal struct Init: SwiftlyCommand {
try FileManager.default.createDirectory(at: confDir, withIntermediateDirectories: true)
profileHome = confDir.appendingPathComponent("swiftly.fish", isDirectory: false)
} else {
let confDir = userHome.appendingPathComponent(".config/fish/conf.d", isDirectory: true)
try FileManager.default.createDirectory(at: confDir, withIntermediateDirectories: true)
let confDir = userHome.appendingPathComponent(
".config/fish/conf.d", isDirectory: true
)
try FileManager.default.createDirectory(
at: confDir, withIntermediateDirectories: true
)
profileHome = confDir.appendingPathComponent("swiftly.fish", isDirectory: false)
}
} else {
Expand Down
4 changes: 1 addition & 3 deletions Sources/Swiftly/Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ struct Install: SwiftlyCommand {
SwiftlyCore.print(" \(swiftlyBinDir.appendingPathComponent(executable).path)")
}

let proceed = SwiftlyCore.readLine(prompt: "Proceed? [y/N]") ?? "n"

guard proceed == "y" else {
guard SwiftlyCore.promptForConfirmation(defaultBehavior: false) else {
throw SwiftlyError(message: "Toolchain installation has been cancelled")
}
}
Expand Down