class Rooibos::Command::Open

Opens a file or URL with the systemโ€™s default application.

Terminal applications often need to hand off to external programs. Opening a PDF, launching a URL, or viewing an image requires platform-specific commands.

This command detects the platform and runs the appropriate opener: open on macOS, xdg-open on Linux, start on Windows.

On success (exit 0), sends Message::Open. On failure (non-zero), sends Message::Error.

Prefer the Command.open factory method for convenience.

Example

# Using the factory method (recommended)
Command.open(model.selected_file)
Command.open("https://rooibos.run")

# Using the class directly
Open.new(path: model.selected_file, envelope: model.selected_file)

# Pattern-match on the response
def update(msg, model)
  case msg
  in { type: :open, envelope: path }
    model.with(status: "Opened #{path}")
  in { type: :error, envelope: path }
    model.with(error: "Could not open #{path}")
  end
end