-
Notifications
You must be signed in to change notification settings - Fork 3
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
Update Commands to use libhostmgr #51
Conversation
2697133
to
3ddfd80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of my comments are blocking.
Unfortunately, I wasn't able to test this properly because "Error: InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records."
struct Constants { | ||
static let s3Key = "authorized_keys" | ||
static let destination = Configuration.shared.localAuthorizedKeys | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. I once saw this kind of information container type being an enum
, which I found neat because it prevents doing _ = Constants()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Done in e7eabdb
} | ||
|
||
// In the case of invalid input like this, show the help text | ||
guard let identifier = self.identifier else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. This could become shorter thanks to SE-0345, see wordpress-mobile/WordPress-iOS#19549
guard let identifier = self.identifier else { | |
guard let identifier else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice! I've been using it for if let
, but I guess it makes sense this would also work for guard let
!
Cleaned up in 3c22054
.forEach { try $0.shutdown(immediately: immediately) } | ||
if all { | ||
try libhostmgr.stopAllRunningVMs(immediately: self.immediately) | ||
Console.exit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add a return
here, just in case something changes in Console.exit()
?
If so, what do you think of using guard all == false else ...
to ensure return
is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm interesting – I wouldn't expect Console.exit()
to ever do anything except stop the application. It has the return type Never
, so it's just as valid as throws
for breaking out of the current scope, and the type system ensures that we can't accidentally change this.
That said, using guard
here would allow the type system to enforce this for us, so I've done that in b23a49e.
# Conflicts: # Sources/hostmgr/commands/sync/SyncAuthorizedKeysCommand.swift
Co-authored-by: Gio Lodi <gio@mokacoding.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've verified all commands listed in the PR description work on my mac. 👍
Builds on #46 by migrating the
hostmgr
CLI commands to uselibhostmgr
under the hood.This uses far less code to do the job, and finishes threading
async
support all the way up to the UI layer.To Test:
Running each command should be a good way to test – you can try:
swift run hostmgr vm list
[should emit a list of VMs, local and remote]swift run hostmgr vm exists xcode-99
[should exit with an error saying the VM doesn't exist]swift run hostmgr vm clean
[should run with empty output]swift run hostmgr vm fetch xcode-14.2
[should download the VM and unpack it]swift run hostmgr vm start xcode-14.2
[should fire up the VM]swift run hostmgr vm stop --all --immediately
[should immediately pull the plug on the VM]