turtle
turtle copied to clipboard
GH-115: Multiplatform open command
Checklist
- [X] I've read the guide for contributing.
- [X] I've checked there are no other open pull requests for the same change.
- [X] I've formatted all code changes with
./gradlew lcCodeFormat
. - [X] I've ran all checks with
./gradlew lcChecks
. - [X] I've updated documentation if needed.
- [x] I've added or updated tests for changes.
Reason for change
Closes #115
Description
- There was already
openFile
that works on Mac and takes a path. This path could actually be a web URL or a file path. - Added
open
thatopenFile
just calls, to avoid changing public API. - Make
open
run different commands for Mac, Windows and Linux to make it multiplatform.
So now that can be simplified quite a bit :)
object Multiplatform {
/**
* Open a given url in the default browser
*/
fun openUrl(url: URL): Command = when(OS.current) {
Mac -> Executable("open") + Arguments(url)
Linux -> Executable("xdg-open") + Arguments(url)
Windows -> Executable("cmd.exe") + Arguments("/c", url))
}
}
@jmfayard you beat me to it, I was going to check if this PR could change based on the other changes.
Although the main reason this has sat open is I need to actually test it on Windows and Linux.
yes that's the hard part, I was wondering what's the best way to have Linx/Windows VM on my mac