diff options
author | Canop <cano.petrole@gmail.com> | 2019-07-03 21:26:22 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-07-03 21:26:22 +0200 |
commit | 4f38fb23c8822e9f6dd610cc8f5c1dd8ba96bf8f (patch) | |
tree | f014aff95865b79bfc1909f5e3bbe54b8d082fbc | |
parent | beb05596a01a6ae40b23878a0fe273db0e8303b5 (diff) |
Hitting enter when first line is selected, or clicking it, goes up to the parent directoryv0.8.6
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | Cargo.lock | 42 | ||||
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | src/app.rs | 14 | ||||
-rw-r--r-- | src/browser_states.rs | 165 | ||||
-rw-r--r-- | src/browser_verbs.rs | 5 | ||||
-rw-r--r-- | src/cli.rs | 21 | ||||
-rw-r--r-- | src/fuzzy_patterns.rs | 2 | ||||
-rw-r--r-- | src/help_states.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 7 | ||||
-rw-r--r-- | src/skin.rs | 4 | ||||
-rw-r--r-- | src/verbs.rs | 7 | ||||
-rw-r--r-- | website/docs/documentation/usage.md | 1 |
13 files changed, 99 insertions, 183 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index eb2229e..c6d6396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +<a name="v0.8.6"></a> +### v0.8.6 - 2019-07-03 +- Hitting enter when first line is selected, or clicking it, goes up to the parent directory +- detect and color executable files on windows +- new toggle to display dates of files (last modification) +- a few small improvements + <a name="v0.8.5"></a> ### v0.8.5 - 2019-06-20 - minor cosmetic changes (this version was mostly released to ensure consistency with termimad's crate) @@ -98,11 +98,10 @@ dependencies = [ "is_executable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mimalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "opener 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "termimad 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "termimad 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "users 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -155,14 +154,6 @@ dependencies = [ ] [[package]] -name = "cmake" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -396,15 +387,6 @@ version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "libmimalloc-sys" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -423,17 +405,8 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "mimalloc" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "libmimalloc-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "minimad" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -629,12 +602,12 @@ dependencies = [ [[package]] name = "termimad" -version = "0.3.9" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "minimad 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "minimad 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -750,7 +723,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum crossbeam 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b14492071ca110999a20bf90e3833406d5d66bfd93b4e52ec9539025ff43fe0d" "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" @@ -777,12 +749,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum is_executable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "302d553b8abc8187beb7d663e34c065ac4570b273bc9511a50e940e99409c577" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" -"checksum libmimalloc-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbc5c496cf16c91375fcad79b3eac1bab8dbe2ac8551c27d1c592de2bcd35ca" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum mimalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d5f44e12401f869ac18554155b464773a712358621e7c43a3e1e8cc6190" -"checksum minimad 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fd17a44f57a2290f7125cfe1b14af82604d02e39ad7cc30d61d977d71f20c3f2" +"checksum minimad 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4da5ff0a9879ad10f42d176deaf82f43e4102d04d9658faf19854d933f236f7c" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" @@ -808,7 +778,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" -"checksum termimad 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f3b63f01f79bd030331dba58f92841387b10b3631b53b7c72ee46f1d36a40c8" +"checksum termimad 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7c0764b3fbcf90f5049815927c45726e67d5ede9d4315cbb26e7433ff3e67bf" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" @@ -1,6 +1,6 @@ [package] name = "broot" -version = "0.8.5" +version = "0.8.6" authors = ["dystroy <denys.seguret@gmail.com>"] repository = "https://github.com/Canop/broot" description = "Fuzzy Search + tree + cd" @@ -24,11 +24,10 @@ glob = "0.3" crossbeam = "0.7" opener = "0.4" crossterm = "0.9.6" -termimad = "0.3.9" +termimad = "0.4.0" #termimad = { path = "../termimad" } [target.'cfg(unix)'.dependencies] -mimalloc = { version = "0.1.3", default-features = false } users = "0.9" [target.'cfg(windows)'.dependencies] @@ -96,20 +96,10 @@ impl App { } fn mut_state(&mut self) -> &mut Box<dyn AppState> { - match self.states.last_mut() { - Some(s) => s, - None => { - panic!("No path has been pushed"); - } - } + self.states.last_mut().expect("No path has been pushed") } fn state(&self) -> &Box<dyn AppState> { - match self.states.last() { - Some(s) => s, - None => { - panic!("No path has been pushed"); - } - } + self.states.last().expect("No path has been pushed") } /// execute all the pending tasks until there's none remaining or diff --git a/src/browser_states.rs b/src/browser_states.rs index c6f51b5..5e1aecf 100644 --- a/src/browser_states.rs +++ b/src/browser_states.rs @@ -54,10 +54,7 @@ impl BrowserState { screen: &Screen, change_options: &dyn Fn(&mut TreeOptions), ) -> AppStateCmdResult { - let tree = match &self.filtered_tree { - Some(tree) => &tree, - None => &self.tree, - }; + let tree = self.displayed_tree(); let mut options = tree.options.clone(); change_options(&mut options); AppStateCmdResult::from_optional_state( @@ -75,11 +72,16 @@ impl BrowserState { i32::from(screen.h) - 2 } + /// return a reference to the currently displayed tree, which + /// is the filtered tree if there's one, the base tree if not. pub fn displayed_tree(&self) -> &Tree { - match &self.filtered_tree { - Some(tree) => &tree, - None => &self.tree, - } + self.filtered_tree.as_ref().unwrap_or(&self.tree) + } + + /// return a mutable reference to the currently displayed tree, which + /// is the filtered tree if there's one, the base tree if not. + pub fn displayed_tree_mut(&mut self) -> &mut Tree { + self.filtered_tree.as_mut().unwrap_or(&mut self.tree) } fn open_selection( @@ -87,40 +89,41 @@ impl BrowserState { screen: &mut Screen, con: &AppContext, ) -> io::Result<AppStateCmdResult> { - let tree = match &self.filtered_tree { - Some(tree) => tree, - None => &self.tree, - }; - if tree.selection == 0 { - Ok(AppStateCmdResult::Keep) - } else { - let line = tree.selected_line(); - let tl = TaskLifetime::unlimited(); - match &line.line_type { - LineType::File => { - opener(line.path.clone(), line.is_exe(), con) - } - LineType::Dir | LineType::SymLinkToDir(_) => { - Ok(AppStateCmdResult::from_optional_state( - BrowserState::new( - line.target(), - tree.options.without_pattern(), - screen, - &tl, - ), - Command::new(), - )) - } - LineType::SymLinkToFile(target) => { - opener( - PathBuf::from(target), - line.is_exe(), // today this always return false - con, - ) - } - _ => { - unreachable!(); + let tree = self.displayed_tree(); + let line = tree.selected_line(); + let tl = TaskLifetime::unlimited(); + match &line.line_type { + LineType::File => { + opener(line.path.clone(), line.is_exe(), con) + } + LineType::Dir | LineType::SymLinkToDir(_) => { + let mut target = line.target(); + if tree.selection == 0 { + // opening the root would be going to where we already are. + // We go up one level instead + if let Some(parent) = target.parent() { + target = PathBuf::from(parent); + } } + Ok(AppStateCmdResult::from_optional_state( + BrowserState::new( + target, + tree.options.without_pattern(), + screen, + &tl, + ), + Command::new(), + )) + } + LineType::SymLinkToFile(target) => { + opener( + PathBuf::from(target), + line.is_exe(), // today this always return false + con, + ) + } + _ => { + unreachable!(); } } } @@ -169,48 +172,24 @@ impl AppState for BrowserState { } } Action::MoveSelection(dy) => { - match self.filtered_tree { - Some(ref mut tree) => { - tree.move_selection(*dy, page_height); - } - None => { - self.tree.move_selection(*dy, page_height); - } - }; + self.displayed_tree_mut().move_selection(*dy, page_height); Ok(AppStateCmdResult::Keep) } Action::ScrollPage(dp) => { - if page_height < self.displayed_tree().lines.len() as i32 { + let tree = self.displayed_tree_mut(); + if page_height < tree.lines.len() as i32 { let dy = dp * page_height; - match self.filtered_tree { - Some(ref mut tree) => { - tree.try_scroll(dy, page_height); - } - None => { - self.tree.try_scroll(dy, page_height); - } - } + tree.try_scroll(dy, page_height); } Ok(AppStateCmdResult::Keep) } Action::Click(_, y) => { let y = *y as i32 - 1; // click position starts at (1, 1) - match self.filtered_tree { - Some(ref mut tree) => { - tree.try_select_y(y); - } - None => { - self.tree.try_select_y(y); - } - }; + self.displayed_tree_mut().try_select_y(y); Ok(AppStateCmdResult::Keep) } Action::DoubleClick(_, y) => { - let tree = match &self.filtered_tree { - Some(tree) => tree, - None => &self.tree, - }; - if tree.selection + 1 == *y as usize { + if self.displayed_tree().selection + 1 == *y as usize { self.open_selection(screen, con) } else { // A double click always come after a simple click at @@ -221,11 +200,7 @@ impl AppState for BrowserState { } Action::OpenSelection => self.open_selection(screen, con), Action::AltOpenSelection => { - let tree = match &self.filtered_tree { - Some(tree) => tree, - None => &self.tree, - }; - let line = tree.selected_line(); + let line = self.displayed_tree().selected_line(); let cd_idx = con.verb_store.index_of("cd"); con.verb_store.verbs[cd_idx].to_cmd_result(&line.target(), &None, screen, con) } @@ -264,7 +239,7 @@ impl AppState for BrowserState { Action::Refresh => Ok(AppStateCmdResult::RefreshState), Action::Quit => Ok(AppStateCmdResult::Quit), Action::Next => { - if let Some(ref mut tree) = self.filtered_tree { + if let Some(tree) = &mut self.filtered_tree { tree.try_select_next_match(); tree.make_selection_visible(page_height); } @@ -339,10 +314,10 @@ impl AppState for BrowserState { fn write_status(&self, screen: &mut Screen, cmd: &Command, con: &AppContext) -> io::Result<()> { match &cmd.action { - Action::FuzzyPatternEdit(_) => { + Action::FuzzyPatternEdit(s) if s.len() > 0 => { screen.write_status_text("Hit <enter> to select, <esc> to remove the filter") } - Action::RegexEdit(_, _) => { + Action::RegexEdit(s, _) if s.len() > 0 => { screen.write_status_text("Hit <enter> to select, <esc> to remove the filter") } Action::VerbEdit(invocation) => { @@ -354,10 +329,7 @@ impl AppState for BrowserState { if let Some(err) = verb.match_error(invocation) { screen.write_status_err(&err) } else { - let line = match &self.filtered_tree { - Some(tree) => tree.selected_line(), - None => self.tree.selected_line(), - }; + let line = self.displayed_tree().selected_line(); screen.write_status_text( &format!( "Hit <enter> to {} : {}", @@ -378,7 +350,7 @@ impl AppState for BrowserState { let tree = self.displayed_tree(); if tree.selection == 0 { screen.write_status_text( - "Hit <enter> to quit, '?' for help, or a few letters to search", + "Hit <esc> to go back, <enter> to go up, '?' for help, or a few letters to search", ) } else { let line = &tree.lines[tree.selection]; @@ -410,30 +382,23 @@ impl AppState for BrowserState { } fn write_flags(&self, screen: &mut Screen, _con: &AppContext) -> io::Result<()> { - let tree = match &self.filtered_tree { - Some(tree) => &tree, - None => &self.tree, - }; + let tree = self.displayed_tree(); let total_char_size = 9; screen.goto(screen.w - total_char_size, screen.h); let terminal = crossterm::Terminal::new(); terminal.clear(crossterm::ClearType::UntilNewLine)?; + let h_value = if tree.options.show_hidden { 'y' } else { 'n' }; + let gi_value = match tree.options.respect_git_ignore { + OptionBool::Auto => 'a', + OptionBool::Yes => 'y', + OptionBool::No => 'n', + }; print!( "{}{} {}{}", screen.skin.flag_label.apply_to(" h:"), - screen - .skin - .flag_value - .apply_to(if tree.options.show_hidden { 'y' } else { 'n' }), + screen.skin.flag_value.apply_to(h_value), screen.skin.flag_label.apply_to(" gi:"), - screen - .skin - .flag_value - .apply_to(match tree.options.respect_git_ignore { - OptionBool::Auto => 'a', - OptionBool::Yes => 'y', - OptionBool::No => 'n', - }), + screen.skin.flag_value.apply_to(gi_value), ); Ok(()) } diff --git a/src/browser_verbs.rs b/src/browser_verbs.rs index abb5940..111cdd7 100644 --- a/src/browser_verbs.rs +++ b/src/browser_verbs.rs @@ -23,10 +23,7 @@ impl VerbExecutor for BrowserState { if let Some(err) = verb.match_error(invocation) { return Ok(AppStateCmdResult::DisplayError(err)); } - let tree = match &self.filtered_tree { - Some(tree) => &tree, - None => &self.tree, - }; + let tree = self.displayed_tree(); let line = &tree.selected_line(); Ok(match verb.execution.as_ref() { ":back" => AppStateCmdResult::PopState, @@ -1,15 +1,16 @@ /// this module manages reading and translating /// the arguments passed on launch of the application. -use crate::errors::{ProgramError, TreeBuildError}; -use crate::tree_options::TreeOptions; -use clap; + use std::env; use std::io; use std::path::PathBuf; use std::result::Result; -use crossterm::Color::*; -use termimad::{rgb, Alignment, MadSkin}; +use crossterm::Color::{self, *}; +use termimad::{Alignment, MadSkin}; + +use crate::errors::{ProgramError, TreeBuildError}; +use crate::tree_options::TreeOptions; pub struct AppLaunchArgs { pub root: PathBuf, // what should be the initial root @@ -175,15 +176,9 @@ pub fn ask_authorization() -> io::Result<bool> { pub fn mad_skin() -> MadSkin { let mut skin = MadSkin::default(); - skin.set_headers_fg(rgb!(255, 187, 0)); + skin.set_headers_fg(Color::AnsiValue(178)); skin.bold.set_fg(Yellow); - skin.italic.set_fgbg(Magenta, rgb!(30, 30, 40)); - skin.scrollbar.set_track_fg(Rgb { - r: 30, - g: 30, - b: 40, - }); - skin.scrollbar.set_thumb_fg(Rgb { r: 67, g: 51, b: 0 }); + skin.italic.set_fg(Magenta); skin.code.align = Alignment::Center; skin } diff --git a/src/fuzzy_patterns.rs b/src/fuzzy_patterns.rs index a982e56..55dea55 100644 --- a/src/fuzzy_patterns.rs +++ b/src/fuzzy_patterns.rs @@ -124,7 +124,7 @@ impl FuzzyPattern { } // return the number of results we should find before starting to // sort them (unless time is runing out). - pub fn optimal_result_number(&self, targeted_size: usize) -> usize { + pub const fn optimal_result_number(&self, targeted_size: usize) -> usize { 20 * targeted_size } } diff --git a/src/help_states.rs b/src/help_states.rs index d3bff10..04c4475 100644 --- a/src/help_states.rs +++ b/src/help_states.rs @@ -85,7 +85,7 @@ impl AppState for HelpState { fn write_status(&self, screen: &mut Screen, cmd: &Command, con: &AppContext) -> io::Result<()> { match &cmd.action { Action::VerbEdit(invocation) => match con.verb_store.search(&invocation.key) { - PrefixSearchResult::NoMatch => screen.write_status_err("No matching verb)"), + PrefixSearchResult::NoMatch => screen.write_status_err("No matching verb"), PrefixSearchResult::Match(verb) => { if let Some(err) = verb.match_error(invocation) { screen.write_status_err(&err) diff --git a/src/main.rs b/src/main.rs index 1ac434b..e7d7f2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,3 @@ -#[cfg(unix)] -use mimalloc::MiMalloc; -#[cfg(unix)] -#[global_allocator] -static GLOBAL: MiMalloc = MiMalloc; #[macro_use] extern crate lazy_static; @@ -85,8 +80,6 @@ fn configure_log() { env!("CARGO_PKG_VERSION"), level ); - #[cfg(unix)] - info!("allocator: Mimalloc"); } } diff --git a/src/skin.rs b/src/skin.rs index 822d631..bb0129b 100644 --- a/src/skin.rs +++ b/src/skin.rs @@ -132,8 +132,8 @@ impl Skin { if let Some(c) = self.help_headers.fg_color { ms.set_headers_fg(c); } - ms.scrollbar.set_track_object_style(&self.scrollbar_track); - ms.scrollbar.set_thumb_object_style(&self.scrollbar_thumb); + ms.scrollbar.track.set_compound_style(CompoundStyle::from(self.scrollbar_track.clone())); + ms.scrollbar.thumb.set_compound_style(CompoundStyle::from(self.scrollbar_thumb.clone())); ms } } diff --git a/src/verbs.rs b/src/verbs.rs index cafeae4..45d01e6 100644 --- a/src/verbs.rs +++ b/src/verbs.rs @@ -80,10 +80,9 @@ impl Verb { invocation: invocation_str.to_string(), }); } - let args_parser = match &invocation.args { - Some(ref args) => Some(make_invocation_args_regex(&args)?), - None => None, - }; + let args_parser = invocation.args.as_ref() + .map(|args| make_invocation_args_regex(&args)) + .transpose()?; Ok(Verb { invocation, args_parser, diff --git a/website/docs/documentation/usage.md b/website/docs/documentation/usage.md index f630b7f..edcdce4 100644 --- a/website/docs/documentation/usage.md +++ b/website/docs/documentation/usage.md @@ -28,6 +28,7 @@ From here you may navigate using the following keys: * <kbd class=b>↓</kbd> or <kbd class=b>↑</kbd> : select the next or previous line * <kbd class=b>⏎</kbd> on a simple file : leave broot and open the file using xdg-open * <kbd class=b>⏎</kbd> on a directory : focus the directory (i.e. make it the new root) +* <kbd class=b>⏎</kbd> on the first line : goes up one level (focus the parent directory) * <kbd>esc</kbd> gets you back to the previous state (or leave broot if there's none) * <kbd>F5</kbd> refreshes the page * <kbd>alt</kbd> + <kbd class=b>⏎</kbd> on a directory : leave broot and `cd` the shell to that directory. |