summaryrefslogtreecommitdiffstats
path: root/src/commands/open_file.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-08-06 14:02:51 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-08-06 14:02:51 -0400
commite0bbe7f3890ee66acfc83357720c9bfabf782c39 (patch)
tree5cbffcecf97b9db516448cce5614d5aebcdb6a03 /src/commands/open_file.rs
parentc176412f865c14f90a2392e93421f0523ae3b11b (diff)
make usercache persistent
Diffstat (limited to 'src/commands/open_file.rs')
-rw-r--r--src/commands/open_file.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index 5eb8493..8b60a2f 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -68,7 +68,7 @@ impl OpenFile {
}
let mimetype_options = Self::get_options(&paths[0]);
if !mimetype_options.is_empty() {
- mimetype_options[0].execute_with(&paths);
+ mimetype_options[0].execute_with(&paths)?;
} else if context.config_t.xdg_open {
ncurses::savetty();
ncurses::endwin();
@@ -76,7 +76,7 @@ impl OpenFile {
ncurses::resetty();
ncurses::refresh();
} else {
- OpenFileWith::open_with(&paths);
+ OpenFileWith::open_with(&paths)?;
}
let curr_tab = &mut context.tabs[context.curr_tab_index];
if curr_tab.curr_list.need_update() {
@@ -137,7 +137,7 @@ impl OpenFileWith {
"open_file_with"
}
- pub fn open_with(paths: &[&PathBuf]) -> JoshutoResult<()> {
+ pub fn open_with(paths: &[&PathBuf]) -> std::io::Result<()> {
const PROMPT: &str = ":open_with ";
let mimetype_options: Vec<&JoshutoMimetypeEntry> = OpenFile::get_options(&paths[0]);
@@ -174,27 +174,23 @@ impl OpenFileWith {
Some(user_input) => match user_input.parse::<usize>() {
Ok(n) => {
if n < mimetype_options.len() {
- mimetype_options[n].execute_with(paths);
- Ok(())
+ mimetype_options[n].execute_with(paths)
} else {
- Err(JoshutoError::new(
- JoshutoErrorKind::IOInvalidData,
+ let err = std::io::Error::new(
+ std::io::ErrorKind::InvalidData,
"option does not exist".to_owned(),
- ))
+ );
+ Err(err)
}
}
Err(_) => {
let mut args_iter = user_input.split_whitespace();
match args_iter.next() {
- Some(s) => {
- let command = String::from(s);
- JoshutoMimetypeEntry::new(command)
+ Some(s) => JoshutoMimetypeEntry::new(s.to_owned())
.add_args(args_iter)
- .execute_with(paths);
- }
- None => {}
+ .execute_with(paths),
+ None => Ok(()),
}
- Ok(())
}
},
}
@@ -222,7 +218,7 @@ impl JoshutoRunnable for OpenFileWith {
Some(_) => {}
}
let paths = curr_list.get_selected_paths();
- Self::open_with(&paths);
+ Self::open_with(&paths)?;
Ok(())
}
}