opener
opener is a Gleam package to open files and URLs using platform-specific commands. It provides a simple interface for executing commands based on the operating system.
gleam add opener@1
import gleam/io
import opener
fn main() -> Nil {
case opener.open("https://gleam.run") {
Ok(_) -> io.println("opened https://gleam.run in default browser")
Error(err) -> io.println("failed to open: https://gleam.run: " <> err.1)
}
}
Features
- Platform detection to determine the appropriate command for opening files or URLs.
- Support for macOS, Windows, and Linux.
Further documentation can be found at https://hexdocs.pm/opener.
Development
gleam run # Run the project
gleam test # Run the tests