-
Notifications
You must be signed in to change notification settings - Fork 51
Add ability to temporarily unlink swiftly #315
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
267cc5a
Add ability to temporarily disable swiftly
plemarquand 998b580
Print message to reload shell
plemarquand 41d6863
Format code
plemarquand de11914
Update documentation
plemarquand bc17ef1
Return swiftly bin path, even in tests
plemarquand a8a107e
Refactor config loading, use in use toolchain when linking
plemarquand cb50330
Address comments
plemarquand 1847095
Address comments
plemarquand a60a675
Notify swiftly is unlinked when performing use, install and update
plemarquand 6262ad7
Revert change that prevented install tests from actually installing
plemarquand 223c001
Refactor validateLinked, fix typo
plemarquand 7223dcb
Mock out toolchain in link/unlink tests
plemarquand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import ArgumentParser | ||
import Foundation | ||
import SwiftlyCore | ||
|
||
struct Link: SwiftlyCommand { | ||
public static let configuration = CommandConfiguration( | ||
abstract: "Link swiftly so it resumes management of the active toolchain." | ||
) | ||
|
||
@Argument(help: ArgumentHelp( | ||
"Links swiftly if it has been disabled.", | ||
discussion: """ | ||
|
||
Links swiftly if it has been disabled. | ||
""" | ||
)) | ||
var toolchainSelector: String? | ||
|
||
@OptionGroup var root: GlobalOptions | ||
|
||
mutating func run() async throws { | ||
try await self.run(Swiftly.createDefaultContext()) | ||
} | ||
|
||
mutating func run(_ ctx: SwiftlyCoreContext) async throws { | ||
let versionUpdateReminder = try await validateSwiftly(ctx) | ||
defer { | ||
versionUpdateReminder() | ||
} | ||
|
||
var config = try await Config.load(ctx) | ||
let toolchainVersion = try await Install.determineToolchainVersion( | ||
ctx, | ||
version: config.inUse?.name, | ||
config: &config | ||
) | ||
|
||
let pathChanged = try await Install.setupProxies( | ||
ctx, | ||
version: toolchainVersion, | ||
verbose: self.root.verbose, | ||
assumeYes: self.root.assumeYes | ||
) | ||
|
||
if pathChanged { | ||
await ctx.print(""" | ||
Linked swiftly to Swift \(toolchainVersion.name). | ||
|
||
\(Messages.refreshShell) | ||
""") | ||
} else { | ||
await ctx.print(""" | ||
Swiftly is already linked to Swift \(toolchainVersion.name). | ||
""") | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.