Open a URL in the default web browser from a MoonBit program, on macOS, Linux (including WSL) and Windows.
Dependencies
moon add bobzhang/open_in_browserasync fn main {
match @open_in_browser.open("http://127.0.0.1:8080/") {
Launched => println("opened it in your browser")
Skipped(why) => println("not opening a browser \{why}; open the link yourself")
Failed(error) => println("could not open a browser (\{error})")
}
}| Where | Command |
|---|---|
| $BROWSER set | each :-separated entry in turn (; on Windows); %s is replaced by the URL, otherwise the URL is appended |
| macOS | open <url> |
| Windows | rundll32 url.dll,FileProtocolHandler <url>: one argument, no shell, so ?, & and # are safe |
| Linux under WSL | wslview <url>, then explorer.exe <url> |
| Linux | xdg-open <url> |
match @open_in_browser.open("http://127.0.0.1:8080/") {
Launched => println("opened it in your browser")
Skipped(why) => println("not opening a browser \{why}")
Failed(error) => println("could not open a browser: \{error}")
}Install
Download zipOpen a URL in the default web browser from a MoonBit program, on macOS, Linux (including WSL) and Windows.
Dependencies