Skip to content

Commit

Permalink
open application now reads OPEN_WITH environment variable to obta…
Browse files Browse the repository at this point in the history
…in the program to open with. (#80)

This is helpful when testing new features around the `with()` function.
  • Loading branch information
Byron committed Jun 21, 2023
1 parent b4592a4 commit 659b8a0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 659b8a0

Please sign in to comment.