mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-06 02:29:57 +02:00
Abstract URL opening in utility, use Url instances
This commit is contained in:
parent
c2611049df
commit
a4aa1b93e5
5 changed files with 32 additions and 11 deletions
|
@ -1,4 +1,9 @@
|
|||
use std::process::exit;
|
||||
extern crate open;
|
||||
|
||||
use std::io::Error as IoError;
|
||||
use std::process::{exit, ExitStatus};
|
||||
|
||||
use ffsend_api::url::Url;
|
||||
|
||||
/// Quit the application with an error code,
|
||||
/// and print the given error message.
|
||||
|
@ -9,3 +14,15 @@ pub fn quit_error<S: AsRef<str>>(err: S) -> ! {
|
|||
// Quit
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/// Open the given URL in the users default browser.
|
||||
/// The browsers exit statis is returned.
|
||||
pub fn open_url(url: Url) -> Result<ExitStatus, IoError> {
|
||||
open_path(url.as_str())
|
||||
}
|
||||
|
||||
/// Open the given path or URL using the program configured on the system.
|
||||
/// The program exit statis is returned.
|
||||
pub fn open_path(path: &str) -> Result<ExitStatus, IoError> {
|
||||
open::that(path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue