mirror of
https://github.com/chmln/handlr.git
synced 2024-11-14 21:49:27 +01:00
cleanup
This commit is contained in:
parent
e33f52cbb5
commit
66bcde83f4
5 changed files with 15 additions and 11 deletions
|
@ -2,4 +2,4 @@ mod system;
|
|||
mod user;
|
||||
|
||||
pub use system::SystemApps;
|
||||
pub use user::MimeApps;
|
||||
pub use user::{MimeApps, Rule as MimeappsRule};
|
||||
|
|
|
@ -89,10 +89,7 @@ impl MimeApps {
|
|||
}
|
||||
pub fn read() -> Result<Self> {
|
||||
let raw_conf = std::fs::read_to_string(Self::path()?)?;
|
||||
let file = Self::parse(Rule::file, &raw_conf)
|
||||
.expect("unsuccessful parse") // unwrap the parse result
|
||||
.next()
|
||||
.unwrap();
|
||||
let file = Self::parse(Rule::file, &raw_conf)?.next().unwrap();
|
||||
|
||||
let mut current_section_name = "".to_string();
|
||||
let mut conf = Self {
|
||||
|
|
|
@ -42,14 +42,19 @@ impl DesktopEntry {
|
|||
Ok(())
|
||||
}
|
||||
fn exec_inner(&self, arg: Vec<String>) -> Result<()> {
|
||||
let (cmd, args) = self.get_cmd(arg)?;
|
||||
let mut cmd = Command::new(cmd);
|
||||
cmd.args(args);
|
||||
let mut cmd = {
|
||||
let (cmd, args) = self.get_cmd(arg)?;
|
||||
let mut cmd = Command::new(cmd);
|
||||
cmd.args(args);
|
||||
cmd
|
||||
};
|
||||
|
||||
if self.term {
|
||||
cmd.status()?;
|
||||
} else {
|
||||
cmd.stdout(Stdio::null()).stderr(Stdio::null()).spawn()?;
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub fn get_cmd(&self, arg: Vec<String>) -> Result<(String, Vec<String>)> {
|
||||
|
|
|
@ -4,6 +4,6 @@ mod handler;
|
|||
mod mime_types;
|
||||
|
||||
pub use self::db::{autocomplete as db_autocomplete, SHARED_MIME_DB};
|
||||
pub use desktop_entry::{DesktopEntry, Mode as ExecMode, Rule as PestRule};
|
||||
pub use desktop_entry::{DesktopEntry, Mode as ExecMode, Rule as EntryRule};
|
||||
pub use handler::Handler;
|
||||
pub use mime_types::{MimeOrExtension, MimeType};
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Parse(#[from] pest::error::Error<crate::common::PestRule>),
|
||||
ParseEntry(#[from] pest::error::Error<crate::common::EntryRule>),
|
||||
#[error(transparent)]
|
||||
ParseApps(#[from] pest::error::Error<crate::apps::MimeappsRule>),
|
||||
#[error(transparent)]
|
||||
Io(#[from] std::io::Error),
|
||||
#[error(transparent)]
|
||||
|
@ -16,7 +18,7 @@ pub enum Error {
|
|||
Ambiguous(String),
|
||||
#[error(transparent)]
|
||||
BadMimeType(#[from] mime::FromStrError),
|
||||
#[error("Malformed desktop entry at .{0}")]
|
||||
#[error("malformed desktop entry at .{0}")]
|
||||
BadEntry(std::path::PathBuf),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue