From 659b8a0a6580fb89376daf27822fc08557ccf477 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 21 Jun 2023 21:12:15 +0200 Subject: [PATCH] `open` application now reads `OPEN_WITH` environment variable to obtain the program to open with. (#80) This is helpful when testing new features around the `with()` function. --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index eabef0d..1992ea8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,12 @@ fn main() { } }; - match open::that(&path_or_url) { + let result = match std::env::var("OPEN_WITH").ok() { + Some(program) => open::with(&path_or_url, program), + None => open::that(&path_or_url), + }; + + match result { Ok(()) => println!("Opened '{}' successfully.", path_or_url), Err(err) => { eprintln!("An error occurred when opening '{}': {}", path_or_url, err);