-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::print::{self}; | ||
|
||
pub fn open_link(link: &str, success_prompt: Option<&str>, error_prompt: Option<&str>) -> bool { | ||
match open::that(&link) { | ||
Ok(_) => { | ||
print::success_msg("Opening URL in browser", link); | ||
match success_prompt { | ||
Some(prompt) => print::prompt(prompt), | ||
None => (), | ||
} | ||
true | ||
} | ||
Err(e) => { | ||
print::error!("Cannot launch browser: {e:#}"); | ||
print::prompt(match error_prompt { | ||
Some(prompt) => prompt, | ||
None => "Please paste the URL below into your browser:", | ||
}); | ||
println!("{link}"); | ||
false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters