Skip to main content

launch

Function launch 

Source
pub fn launch(url: &str, wait: bool, locate: bool) -> Result<()>
Expand description

Open a URL or file path in the default application.

Uses platform-specific commands to launch the associated application:

  • macOS: open
  • Linux: xdg-open
  • Windows: start

§Arguments

  • url - The URL or file path to open
  • wait - If true, wait for the application to finish before returning
  • locate - If true, open a file manager showing the file location instead

§Returns

Ok(()) on success, or an error if the launch failed.

§Example

use click::termui::launch;

// Open a URL in the default browser
launch("https://example.com", false, false)?;

// Open a file in its default application
launch("/path/to/document.pdf", false, false)?;

// Show file location in file manager
launch("/path/to/file.txt", false, true)?;