diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app_state.rs | 20 | ||||
-rw-r--r-- | src/browser_states.rs | 20 | ||||
-rw-r--r-- | src/clap.rs | 4 | ||||
-rw-r--r-- | src/cli.rs | 27 | ||||
-rw-r--r-- | src/command_parsing.rs | 4 | ||||
-rw-r--r-- | src/conf.rs | 4 | ||||
-rw-r--r-- | src/external.rs | 2 | ||||
-rw-r--r-- | src/file_sizes/file_sizes_default.rs | 1 | ||||
-rw-r--r-- | src/file_sizes/file_sizes_unix.rs | 2 | ||||
-rw-r--r-- | src/flat_tree.rs | 14 | ||||
-rw-r--r-- | src/fuzzy_patterns.rs | 48 | ||||
-rw-r--r-- | src/git_ignore.rs | 18 | ||||
-rw-r--r-- | src/help_content.rs | 18 | ||||
-rw-r--r-- | src/help_states.rs | 10 | ||||
-rw-r--r-- | src/help_verbs.rs | 20 | ||||
-rw-r--r-- | src/keys.rs | 24 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/mad_skin.rs | 3 | ||||
-rw-r--r-- | src/matched_string.rs | 11 | ||||
-rw-r--r-- | src/screens.rs | 2 | ||||
-rw-r--r-- | src/shell_install/bash.rs | 6 | ||||
-rw-r--r-- | src/shell_install/mod.rs | 12 | ||||
-rw-r--r-- | src/shell_install/util.rs | 2 | ||||
-rw-r--r-- | src/skin_conf.rs | 6 | ||||
-rw-r--r-- | src/task_sync.rs | 11 | ||||
-rw-r--r-- | src/tree_build/bid.rs | 8 | ||||
-rw-r--r-- | src/tree_build/builder.rs | 8 | ||||
-rw-r--r-- | src/verb_conf.rs | 4 | ||||
-rw-r--r-- | src/verb_store.rs | 2 | ||||
-rw-r--r-- | src/verbs.rs | 2 |
30 files changed, 183 insertions, 138 deletions
diff --git a/src/app_state.rs b/src/app_state.rs index 875bc72..5952929 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -1,13 +1,15 @@ -use crate::{ - app_context::AppContext, - browser_states::BrowserState, - commands::Command, - errors::{ProgramError, TreeBuildError}, - external::Launchable, - screens::Screen, - task_sync::TaskLifetime, +use { + crate::{ + app_context::AppContext, + browser_states::BrowserState, + commands::Command, + errors::{ProgramError, TreeBuildError}, + external::Launchable, + screens::Screen, + task_sync::TaskLifetime, + }, + std::io::Write, }; -use std::io::Write; /// Result of applying a command to a state pub enum AppStateCmdResult { diff --git a/src/browser_states.rs b/src/browser_states.rs index ff5af32..e93c323 100644 --- a/src/browser_states.rs +++ b/src/browser_states.rs @@ -241,7 +241,9 @@ impl AppState for BrowserState { if invocation.name.is_empty() { Status::new( task, - mad_inline!("Type a verb then *enter* to execute it (*?* for the list of verbs)"), + mad_inline!( + "Type a verb then *enter* to execute it (*?* for the list of verbs)" + ), false, ) .display(&mut w, screen) @@ -446,17 +448,15 @@ impl AppState for BrowserState { warn!("refreshing base tree failed : {:?}", e); } // refresh the filtered tree, if any - Command::from_pattern( - match self.filtered_tree { - Some(ref mut tree) => { - if let Err(e) = tree.refresh(page_height) { - warn!("refreshing filtered tree failed : {:?}", e); - } - &tree.options.pattern + Command::from_pattern(match self.filtered_tree { + Some(ref mut tree) => { + if let Err(e) = tree.refresh(page_height) { + warn!("refreshing filtered tree failed : {:?}", e); } - None => &self.tree.options.pattern, + &tree.options.pattern } - ) + None => &self.tree.options.pattern, + }) } /// draw the flags at the bottom right of the screen diff --git a/src/clap.rs b/src/clap.rs index 0c2d79f..8e9db5e 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -83,9 +83,7 @@ pub fn clap_app() -> clap::App<'static, 'static> { clap::Arg::with_name("set-install-state") .long("set-install-state") .takes_value(true) - .possible_values( - &["undefined", "refused", "installed"] - ) + .possible_values(&["undefined", "refused", "installed"]) .help("set the installation state (for use in install script)"), ) .arg( @@ -35,19 +35,18 @@ fn canonicalize_root(root: &Path) -> io::Result<PathBuf> { #[cfg(windows)] fn canonicalize_root(root: &Path) -> io::Result<PathBuf> { - Ok( - if root.is_relative() { - env::current_dir()?.join(root) - } else { - root.to_path_buf() - } - ) + Ok(if root.is_relative() { + env::current_dir()?.join(root) + } else { + root.to_path_buf() + }) } /// return the parsed launch arguments pub fn read_launch_args() -> Result<AppLaunchArgs, ProgramError> { let cli_args = crate::clap::clap_app().get_matches(); - let mut root = cli_args.value_of("root") + let mut root = cli_args + .value_of("root") .map_or(env::current_dir()?, PathBuf::from); if !root.exists() { Err(TreeBuildError::FileNotFound { @@ -84,15 +83,9 @@ pub fn read_launch_args() -> Result<AppLaunchArgs, ProgramError> { tree_options.respect_git_ignore = respect_ignore.parse()?; } let install = cli_args.is_present("install"); - let file_export_path = cli_args - .value_of("file_export_path") - .map(str::to_string); - let cmd_export_path = cli_args - .value_of("cmd_export_path") - .map(str::to_string); - let commands = cli_args - .value_of("commands") - .map(str::to_string); + let file_export_path = cli_args.value_of("file_export_path").map(str::to_string); + let cmd_export_path = cli_args.value_of("cmd_export_path").map(str::to_string); + let commands = cli_args.value_of("commands").map(str::to_string); let no_style = cli_args.is_present("no-style"); let height = cli_args.value_of("height").and_then(|s| s.parse().ok()); let print_shell_function = cli_args diff --git a/src/command_parsing.rs b/src/command_parsing.rs index d314116..cbbb6dc 100644 --- a/src/command_parsing.rs +++ b/src/command_parsing.rs @@ -49,12 +49,12 @@ pub fn parse_command_sequence( // of actions with some missing match con.verb_store.search(&invocation.name) { PrefixSearchResult::NoMatch => { - return Err(ProgramError::UnknownVerb{ + return Err(ProgramError::UnknownVerb { name: invocation.name.to_string(), }); } PrefixSearchResult::TooManyMatches(_) => { - return Err(ProgramError::AmbiguousVerbName{ + return Err(ProgramError::AmbiguousVerbName { name: invocation.name.to_string(), }); } diff --git a/src/conf.rs b/src/conf.rs index 437ec09..a9214e6 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -109,7 +109,9 @@ impl Conf { .transpose()?; if let Some(key) = key { if keys::is_reserved(key) { - return Err(ConfError::ReservedKey{key: keys::key_event_desc(key)}); + return Err(ConfError::ReservedKey { + key: keys::key_event_desc(key), + }); } } let execution = match string_field(verb_value, "execution") { diff --git a/src/external.rs b/src/external.rs index 2af3091..daea570 100644 --- a/src/external.rs +++ b/src/external.rs @@ -52,7 +52,7 @@ fn resolve_env_variables(parts: Vec<String>) -> Vec<String> { for part in parts.into_iter() { if part.starts_with('$') { if let Ok(val) = env::var(&part[1..]) { - resolved.extend(val.split(' ').map(|s|s.to_string())); + resolved.extend(val.split(' ').map(|s| s.to_string())); continue; } } diff --git a/src/file_sizes/file_sizes_default.rs b/src/file_sizes/file_sizes_default.rs index ed5832d..0078a05 100644 --- a/src/file_sizes/file_sizes_default.rs +++ b/src/file_sizes/file_sizes_default.rs @@ -1,6 +1,7 @@ //! size computation for non linux use { + super::FileSize, crate::task_sync::TaskLifetime, crossbeam::{channel::unbounded, sync::WaitGroup}, std::{ diff --git a/src/file_sizes/file_sizes_unix.rs b/src/file_sizes/file_sizes_unix.rs index 48940c8..8491699 100644 --- a/src/file_sizes/file_sizes_unix.rs +++ b/src/file_sizes/file_sizes_unix.rs @@ -80,7 +80,7 @@ pub fn compute_dir_size(path: &Path, tl: &TaskLifetime) -> Option<u64> { return None; } let blocks = blocks.load(Ordering::Relaxed); - Some(blocks*512) + Some(blocks * 512) } pub fn compute_file_size(path: &Path) -> FileSize { diff --git a/src/flat_tree.rs b/src/flat_tree.rs index 2da454c..18d2930 100644 --- a/src/flat_tree.rs +++ b/src/flat_tree.rs @@ -183,14 +183,14 @@ impl PartialOrd for TreeLine { impl Tree { pub fn refresh(&mut self, page_height: usize) -> Result<(), errors::TreeBuildError> { let builder = TreeBuilder::from( - self.root().to_path_buf(), - self.options.clone(), - page_height, - )?; + self.root().to_path_buf(), + self.options.clone(), + page_height, + )?; let mut tree = builder.build( - &TaskLifetime::unlimited(), - false, // on refresh we always do a non total search - ).unwrap(); // should not fail + &TaskLifetime::unlimited(), + false, // on refresh we always do a non total search + ).unwrap(); // should not fail // we save the old selection to try restore it let selected_path = self.selected_line().path.to_path_buf(); mem::swap(&mut self.lines, &mut tree.lines); diff --git a/src/fuzzy_patterns.rs b/src/fuzzy_patterns.rs index a3f7bf7..5d878b1 100644 --- a/src/fuzzy_patterns.rs +++ b/src/fuzzy_patterns.rs @@ -119,7 +119,7 @@ impl FuzzyPattern { let previous = cand_chars[start_idx - 1]; if previous == '_' || previous == ' ' || previous == '-' { score += BONUS_START_WORD; - if cand_chars.len()-start_idx == self.lc_chars.len() { + if cand_chars.len() - start_idx == self.lc_chars.len() { return MatchSearchResult::Perfect(Match { score, pos }); } } @@ -206,7 +206,7 @@ impl FuzzyPattern { let previous = cand[start_idx - 1]; if previous == b'_' || previous == b' ' || previous == b'-' { score += BONUS_START_WORD; - if cand.len()-start_idx == self.lc_bytes.len() { + if cand.len() - start_idx == self.lc_bytes.len() { return ScoreSearchResult::Perfect(score); } } @@ -267,7 +267,15 @@ mod fuzzy_pattern_tests { #[test] fn check_equal_scores() { static PATTERNS: &[&str] = &["reveil", "dystroy", "broot", "AB"]; - static NAMES: &[&str] = &[" brr ooT", "Reveillon", "dys", "test", " a reveil", "a rbrroot", "Ab"]; + static NAMES: &[&str] = &[ + " brr ooT", + "Reveillon", + "dys", + "test", + " a reveil", + "a rbrroot", + "Ab", + ]; for pattern in PATTERNS { let fp = FuzzyPattern::from(pattern); for name in NAMES { @@ -287,7 +295,12 @@ mod fuzzy_pattern_tests { let mut last_name = pattern; for name in names { let score = fp.score_of(name); - assert!(score < last_score, "score({:?}) should be lower than score({:?}) (using score_of)", name, last_name); + assert!( + score < last_score, + "score({:?}) should be lower than score({:?}) (using score_of)", + name, + last_name + ); last_name = name; last_score = score; } @@ -296,7 +309,12 @@ mod fuzzy_pattern_tests { let mut last_name = pattern; for name in names { let score = fp.find(name).map(|m| m.score); - assert!(score < last_score, "score({:?}) should be lower than score({:?}) (using find)", name, last_name); + assert!( + score < last_score, + "score({:?}) should be lower than score({:?}) (using find)", + name, + last_name + ); last_name = name; last_score = score; } @@ -306,7 +324,16 @@ mod fuzzy_pattern_tests { fn check_orderings() { check_ordering_for( "broot", - &["a broot", "abbroot", "abcbroot", " abdbroot", "1234broot1", "12345brrrroooottt", "12345brrr roooottt", "brot"], + &[ + "a broot", + "abbroot", + "abcbroot", + " abdbroot", + "1234broot1", + "12345brrrroooottt", + "12345brrr roooottt", + "brot", + ], ); check_ordering_for( "Abc", @@ -314,7 +341,14 @@ mod fuzzy_pattern_tests { ); check_ordering_for( "réveil", - &["Réveillon", "Réveillons", " réveils", "πréveil", "déréveil", " rêves"], + &[ + "Réveillon", + "Réveillons", + " réveils", + "πréveil", + "déréveil", + " rêves", + ], ); } } diff --git a/src/git_ignore.rs b/src/git_ignore.rs index c18e379..cc1b055 100644 --- a/src/git_ignore.rs +++ b/src/git_ignore.rs @@ -3,15 +3,16 @@ //! can apply for a dir (i.e when entering a directory we //! may add a gitignore file to the stack) -use std::{ - fs::File, - io::{BufRead, BufReader, Result}, - path::Path, +use { + glob, + regex::Regex, + std::{ + fs::File, + io::{BufRead, BufReader, Result}, + path::Path, + }, }; -use glob; -use regex::Regex; - /// a simple rule of a gitignore file #[derive(Clone)] struct GitIgnoreRule { @@ -128,7 +129,8 @@ impl GitIgnoreFilter { // we reset the chain: we don't want the .gitignore // files of super repositories // (see https://github.com/Canop/broot/issues/160) - let mut files = if is_git_repo(dir) { // we'll assume it's a .git folder + let mut files = if is_git_repo(dir) { + // we'll assume it's a .git folder debug!("entering a git repo {:?}", dir); self.files.clone() } else { diff --git a/src/help_content.rs b/src/help_content.rs index 985d6fb..137d1a8 100644 --- a/src/help_content.rs +++ b/src/help_content.rs @@ -1,10 +1,11 @@ -use minimad::{ - Text, - TextTemplate, -}; - -use crate::{ - app_context::AppContext, +use { + crate::{ + app_context::AppContext, + }, + minimad::{ + Text, + TextTemplate, + }, }; static MD: &str = r#" @@ -64,7 +65,8 @@ pub fn build_text(con: &AppContext) -> Text<'_> { .set("version", env!("CARGO_PKG_VERSION")) .set("config-path", &con.config_path); for verb in &con.verb_store.verbs { - let sub = expander.sub("verb-rows") + let sub = expander + .sub("verb-rows") .set("name", &verb.invocation.name) .set( "shortcut", diff --git a/src/help_states.rs b/src/help_states.rs index b46944e..6e6011d 100644 --- a/src/help_states.rs +++ b/src/help_states.rs @@ -29,7 +29,7 @@ pub struct HelpState { } impl HelpState { - pub fn new(_screen: &Screen, _con: & AppContext) -> HelpState { + pub fn new(_screen: &Screen, _con: &AppContext) -> HelpState { let area = Area::uninitialized(); // will be fixed at drawing time HelpState { area, @@ -68,7 +68,7 @@ impl AppState for HelpState { Action::Resize(w, h) => { screen.set_terminal_size(*w, *h, con); self.dirty = true; - AppStateCmdResult::RefreshState{clear_cache: false} + AppStateCmdResult::RefreshState { clear_cache: false } } Action::VerbIndex(index) => { let verb = &con.verb_store.verbs[*index]; @@ -106,7 +106,11 @@ impl AppState for HelpState { self.dirty = false; } let text = help_content::build_text(con); - let fmt_text = FmtText::from_text(&screen.help_skin, text, Some((self.area.width - 1) as usize)); + let fmt_text = FmtText::from_text( + &screen.help_skin, + text, + Some((self.area.width - 1) as usize), + ); let mut text_view = TextView::from(&self.area, &fmt_text); self.scroll = text_view.set_scroll(self.scroll); Ok(text_view.write_on(&mut w)?) diff --git a/src/help_verbs.rs b/src/help_verbs.rs index b8adad4..89ffcee 100644 --- a/src/help_verbs.rs +++ b/src/help_verbs.rs @@ -47,18 +47,12 @@ impl VerbExecutor for HelpState { self.scroll -= 1; AppStateCmdResult::Keep } - ":open_stay" => { - match open::that(&Conf::default_location()) { - Ok(exit_status) => { - info!("open returned with exit_status {:?}", exit_status); - AppStateCmdResult::Keep - } - Err(e) => { - AppStateCmdResult::DisplayError( - format!("{:?}", e) - ) - } + ":open_stay" => match open::that(&Conf::default_location()) { + Ok(exit_status) => { + info!("open returned with exit_status {:?}", exit_status); + AppStateCmdResult::Keep } + Err(e) => AppStateCmdResult::DisplayError(format!("{:?}", e)), }, ":open_leave" => AppStateCmdResult::from(Launchable::opener(Conf::default_location())), ":page_down" => { @@ -70,7 +64,9 @@ impl VerbExecutor for HelpState { AppStateCmdResult::Keep } ":print_path" => external::print_path(&Conf::default_location(), con)?, - ":print_relative_path" => external::print_relative_path(&Conf::default_location(), con)?, + ":print_relative_path" => { + external::print_relative_path(&Conf::default_location(), con)? + } ":quit" => AppStateCmdResult::Quit, ":focus_user_home" | ":focus_root" => AppStateCmdResult::PopStateAndReapply, _ if verb.execution.starts_with(":toggle") => AppStateCmdResult::PopStateAndReapply, diff --git a/src/keys.rs b/src/keys.rs index 2e3b78d..a975ecd 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -13,10 +13,16 @@ use { macro_rules! const_key { ($name:ident, $code:expr) => { - pub const $name: KeyEvent = KeyEvent{code:$code, modifiers:KeyModifiers::empty()}; + pub const $name: KeyEvent = KeyEvent { + code: $code, + modifiers: KeyModifiers::empty(), + }; }; ($name:ident, $code:expr, $mod:expr) => { - pub const $name: KeyEvent = KeyEvent{code:$code, modifiers:$mod}; + pub const $name: KeyEvent = KeyEvent { + code: $code, + modifiers: $mod, + }; }; } @@ -91,7 +97,7 @@ pub fn is_reserved(key: KeyEvent) -> bool { /// pub fn parse_key(raw: &str) -> Result<KeyEvent, ConfError> { let tokens: Vec<&str> = raw.split('-').collect(); - let last = tokens[tokens.len()-1].to_ascii_lowercase(); + let last = tokens[tokens.len() - 1].to_ascii_lowercase(); let code = match last.as_ref() { "esc" => Esc, "enter" => Enter, @@ -120,13 +126,13 @@ pub fn parse_key(raw: &str) -> Result<KeyEvent, ConfError> { "f10" => F(10), "f11" => F(11), "f12" => F(12), - c if c.len()==1 => Char(c.chars().next().unwrap()), - _=> { + c if c.len() == 1 => Char(c.chars().next().unwrap()), + _ => { return bad_key(raw); } }; let mut modifiers = KeyModifiers::empty(); - for i in 0..tokens.len()-1 { + for i in 0..tokens.len() - 1 { let token = tokens[i]; match token.to_ascii_lowercase().as_ref() { "ctrl" => { @@ -138,12 +144,12 @@ pub fn parse_key(raw: &str) -> Result<KeyEvent, ConfError> { "shift" => { modifiers.insert(KeyModifiers::SHIFT); } - _=> { + _ => { return bad_key(raw); } } } - Ok(KeyEvent{ code, modifiers }) + Ok(KeyEvent { code, modifiers }) } #[cfg(test)] mod key_parsing_tests { @@ -157,7 +163,7 @@ mod key_parsing_tests { }; #[test] - fn check_key_description(){ + fn check_key_description() { assert_eq!(key_event_desc(ALT_ENTER), "alt-enter"); } @@ -18,9 +18,11 @@ pub mod command_parsing; pub mod commands; pub mod conf; pub mod displayable_tree; +pub mod errors; pub mod external; pub mod file_sizes; pub mod flat_tree; +pub mod fuzzy_patterns; pub mod git_ignore; pub mod help_content; pub mod help_states; @@ -29,7 +31,9 @@ pub mod io; pub mod keys; pub mod mad_skin; pub mod matched_string; +pub mod patterns; pub mod permissions; +pub mod regex_patterns; pub mod screens; pub mod selection_type; pub mod shell_install; @@ -43,8 +47,4 @@ pub mod verb_conf; pub mod verb_invocation; pub mod verb_store; pub mod verbs; -pub mod errors; -pub mod fuzzy_patterns; -pub mod patterns; -pub mod regex_patterns; diff --git a/src/mad_skin.rs b/src/mad_skin.rs index 52dc8e0..a1315f7 100644 --- a/src/mad_skin.rs +++ b/src/mad_skin.rs @@ -79,7 +79,8 @@ pub fn make_help_mad_skin(skin: &Skin) -> MadSkin { if let Some(c) = skin.help_headers.get_bg() { ms.set_headers_bg(c); } - ms.bullet.set_compound_style(ms.paragraph.compound_style.clone()); + ms.bullet + .set_compound_style(ms.paragraph.compound_style.clone()); ms.scrollbar .track .set_compound_style(CompoundStyle::from(skin.scrollbar_track.clone())); diff --git a/src/matched_string.rs b/src/matched_string.rs index 2b993af..00c44a3 100644 --- a/src/matched_string.rs +++ b/src/matched_string.rs @@ -1,11 +1,12 @@ - -use termimad::CompoundStyle; - -use crate::{ - patterns::Pattern, +use { + termimad::CompoundStyle, + crate::{ + patterns::Pattern, + }, }; + pub struct MatchedString<'a> { pub pattern: &'a Pattern, pub string: &'a str, diff --git a/src/screens.rs b/src/screens.rs index 1e346ac..0d2720c 100644 --- a/src/screens.rs +++ b/src/screens.rs @@ -48,7 +48,7 @@ impl Screen { if let Some(h) = con.launch_args.height { self.height = h; } - self.input_field.change_area(0, h-1, w - FLAGS_AREA_WIDTH); + self.input_field.change_area(0, h - 1, w - FLAGS_AREA_WIDTH); } pub fn read_size(&mut self, con: &AppContext) -> Result<(), ProgramError> { let (w, h) = termimad::terminal_size(); diff --git a/src/shell_install/bash.rs b/src/shell_install/bash.rs index ac4ecf0..0ace0a3 100644 --- a/src/shell_install/bash.rs +++ b/src/shell_install/bash.rs @@ -148,7 +148,11 @@ pub fn install(si: &mut ShellInstall) -> Result<(), ProgramError> { for sourcing_path in &sourcing_paths { let sourcing_path_str = sourcing_path.to_string_lossy(); if util::file_contains_line(sourcing_path, &source_line)? { - mad_print_inline!(&si.skin, "`$0` already patched, no change made.\n", &sourcing_path_str); + mad_print_inline!( + &si.skin, + "`$0` already patched, no change made.\n", + &sourcing_path_str + ); } else { let mut shellrc = OpenOptions::new() .write(true) diff --git a/src/shell_install/mod.rs b/src/shell_install/mod.rs index dbc0c38..0613c94 100644 --- a/src/shell_install/mod.rs +++ b/src/shell_install/mod.rs @@ -25,7 +25,7 @@ The function is either missing, old or badly installed. Can I install it now? [**Y** n] "#; -const MD_INSTALL_DONE : &str = r#" +const MD_INSTALL_DONE: &str = r#" The **br** function has been installed. You may have to restart your shell or source your shell init files. Afterwards, you should start broot with `br` in order to use its full power. @@ -128,7 +128,7 @@ impl ShellInstall { "bash" | "zsh" => println!("{}", bash::get_script()), "fish" => println!("{}", fish::get_script()), _ => { - return Err(ProgramError::UnknowShell{ + return Err(ProgramError::UnknowShell { shell: shell.to_string(), }); } @@ -196,7 +196,7 @@ impl ShellInstall { if !proceed { ShellInstallState::Refused.write_file()?; self.skin.print_text( - "**Installation cancelled**. If you change your mind, run `broot --install`." + "**Installation cancelled**. If you change your mind, run `broot --install`.", ); } Ok(proceed) @@ -211,7 +211,11 @@ impl ShellInstall { self.remove(&script_path)?; info!("Writing `br` shell function in `{:?}`", &script_path); let script_path_str = script_path.to_string_lossy(); - mad_print_inline!(&self.skin, "Writing *br* shell function in `$0`.\n", &script_path_str); + mad_print_inline!( + &self.skin, + "Writing *br* shell function in `$0`.\n", + &script_path_str + ); fs::create_dir_all(script_path.parent().unwrap())?; fs::write(&script_path, content)?; Ok(()) diff --git a/src/shell_install/util.rs b/src/shell_install/util.rs index 056eb51..41fd0e2 100644 --- a/src/shell_install/util.rs +++ b/src/shell_install/util.rs @@ -1,6 +1,6 @@ use std::{ - fs::self, + fs, io::{self, BufRead, BufReader}, path::Path, }; diff --git a/src/skin_conf.rs b/src/skin_conf.rs index 01a24e4..b11161f 100644 --- a/src/skin_conf.rs +++ b/src/skin_conf.rs @@ -114,11 +114,7 @@ pub fn parse_object_style(s: &str) -> Result<CompoundStyle, InvalidSkinError> { let fg_color = parse_color(c.name("fg").unwrap().as_str())?; let bg_color = parse_color(c.name("bg").unwrap().as_str())?; let attrs = parse_attributes(c.name("attributes").unwrap().as_str())?; - Ok(CompoundStyle::new( - fg_color, - bg_color, - attrs, - )) + Ok(CompoundStyle::new(fg_color, bg_color, attrs)) } else { debug!("NO match for {:?}", s); Err(InvalidSkinError::InvalidStyle { diff --git a/src/task_sync.rs b/src/task_sync.rs index 4663a35..926d9ed 100644 --- a/src/task_sync.rs +++ b/src/task_sync.rs @@ -1,10 +1,11 @@ -use std::sync::{ - atomic::{AtomicUsize, Ordering}, - Arc, +use { + lazy_static::lazy_static, + std::sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, + }, }; -use lazy_static::lazy_static; - /// a TL initialized from an Arc<AtomicUsize> stays /// alive as long as the passed arc doesn't change. /// When it changes, is_expired returns true diff --git a/src/tree_build/bid.rs b/src/tree_build/bid.rs index e1ebd98..e053af9 100644 --- a/src/tree_build/bid.rs +++ b/src/tree_build/bid.rs @@ -1,11 +1,7 @@ use { + super::bline::BLine, id_arena::Id, - super::{ - bline::BLine, - }, - std::{ - cmp::{self, Ordering}, - }, + std::cmp::{self, Ordering}, }; pub type BId = Id<BLine>; diff --git a/src/tree_build/builder.rs b/src/tree_build/builder.rs index caf5265..9f04494 100644 --- a/src/tree_build/builder.rs +++ b/ |