diff --git a/examples/simple.rs b/examples/simple.rs index 9b26efa3..6ceb208a 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,9 +1,9 @@ use bat::{ assets::HighlightingAssets, + config::Config, controller::Controller, inputfile::InputFile, style::{OutputComponent, OutputComponents}, - config::Config, }; use console::Term; use std::process; diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 4c92d7a9..367f700b 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -18,12 +18,12 @@ use ansi_term; use bat::{ assets::BAT_THEME_DEFAULT, + config::{Config, PagingMode}, errors::*, inputfile::InputFile, line_range::{HighlightedLineRanges, LineRange, LineRanges}, style::{OutputComponent, OutputComponents, OutputWrap}, syntax_mapping::SyntaxMapping, - config::{Config, PagingMode}, }; fn is_truecolor_terminal() -> bool { @@ -201,14 +201,13 @@ impl App { } }) .unwrap_or_else(|| String::from(BAT_THEME_DEFAULT)), - line_ranges: - self.matches - .values_of("line-range") - .map(|vs| vs.map(LineRange::from).collect()) - .transpose()? - .map(LineRanges::from) - .unwrap_or_default() - , + line_ranges: self + .matches + .values_of("line-range") + .map(|vs| vs.map(LineRange::from).collect()) + .transpose()? + .map(LineRanges::from) + .unwrap_or_default(), output_components, syntax_mapping, pager: self.matches.value_of("pager"), @@ -216,14 +215,14 @@ impl App { Some("always") => true, _ => false, }, - highlighted_lines: - self.matches - .values_of("highlight-line") - .map(|ws| ws.map(LineRange::from).collect()) - .transpose()? - .map(LineRanges::from) - .map(|lr| HighlightedLineRanges(lr)) - .unwrap_or_default() + highlighted_lines: self + .matches + .values_of("highlight-line") + .map(|ws| ws.map(LineRange::from).collect()) + .transpose()? + .map(LineRanges::from) + .map(|lr| HighlightedLineRanges(lr)) + .unwrap_or_default(), }) } diff --git a/src/bin/bat/assets.rs b/src/bin/bat/assets.rs index 45060c43..b75db4be 100644 --- a/src/bin/bat/assets.rs +++ b/src/bin/bat/assets.rs @@ -33,5 +33,6 @@ pub fn clear_assets() { } pub fn assets_from_cache_or_binary() -> HighlightingAssets { - HighlightingAssets::from_cache(&theme_set_path(), &syntax_set_path()).unwrap_or(HighlightingAssets::from_binary()) + HighlightingAssets::from_cache(&theme_set_path(), &syntax_set_path()) + .unwrap_or(HighlightingAssets::from_binary()) } diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 66c3a411..48a54ae4 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -7,10 +7,10 @@ extern crate clap; extern crate dirs as dirs_rs; mod app; +mod assets; mod clap_app; mod config; mod directories; -mod assets; use std::collections::HashSet; use std::ffi::OsStr; @@ -23,22 +23,28 @@ use ansi_term::Colour::Green; use ansi_term::Style; use crate::{app::App, config::config_file}; -use directories::PROJECT_DIRS; -use assets::{cache_dir, clear_assets, config_dir, assets_from_cache_or_binary}; +use assets::{assets_from_cache_or_binary, cache_dir, clear_assets, config_dir}; use bat::controller::Controller; +use directories::PROJECT_DIRS; use bat::{ assets::HighlightingAssets, + config::Config, errors::*, inputfile::InputFile, style::{OutputComponent, OutputComponents}, - config::Config, }; fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> { if matches.is_present("build") { - let source_dir = matches.value_of("source").map(Path::new).unwrap_or_else(|| PROJECT_DIRS.config_dir()); - let target_dir = matches.value_of("target").map(Path::new).unwrap_or_else(|| PROJECT_DIRS.cache_dir()); + let source_dir = matches + .value_of("source") + .map(Path::new) + .unwrap_or_else(|| PROJECT_DIRS.config_dir()); + let target_dir = matches + .value_of("target") + .map(Path::new) + .unwrap_or_else(|| PROJECT_DIRS.cache_dir()); let blank = matches.is_present("blank"); diff --git a/src/controller.rs b/src/controller.rs index 5b418a98..7e6b1a67 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -2,12 +2,12 @@ use std::io::{self, Write}; use std::path::Path; use crate::assets::HighlightingAssets; +use crate::config::{Config, PagingMode}; use crate::errors::*; use crate::inputfile::{InputFile, InputFileReader}; use crate::line_range::{LineRanges, RangeCheckResult}; use crate::output::OutputType; use crate::printer::{InteractivePrinter, Printer, SimplePrinter}; -use crate::config::{Config, PagingMode}; pub struct Controller<'a> { config: &'a Config<'a>, diff --git a/src/line_range.rs b/src/line_range.rs index 385448ed..45cb13b8 100644 --- a/src/line_range.rs +++ b/src/line_range.rs @@ -159,7 +159,6 @@ impl Default for HighlightedLineRanges { } } - #[cfg(test)] fn ranges(rs: &[&str]) -> LineRanges { LineRanges::from(rs.iter().map(|r| LineRange::from(r).unwrap()).collect()) diff --git a/src/output.rs b/src/output.rs index 3e82c494..3bad301b 100644 --- a/src/output.rs +++ b/src/output.rs @@ -6,9 +6,9 @@ use std::process::{Child, Command, Stdio}; use shell_words; +use crate::config::PagingMode; use crate::errors::*; use crate::less::retrieve_less_version; -use crate::config::PagingMode; #[derive(Debug)] pub enum OutputType { diff --git a/src/printer.rs b/src/printer.rs index 9e36459f..bae55bea 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -20,6 +20,7 @@ use encoding::{DecoderTrap, Encoding}; use unicode_width::UnicodeWidthChar; use crate::assets::HighlightingAssets; +use crate::config::Config; use crate::decorations::{ Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration, }; @@ -31,7 +32,6 @@ use crate::line_range::RangeCheckResult; use crate::preprocessor::{expand_tabs, replace_nonprintable}; use crate::style::OutputWrap; use crate::terminal::{as_terminal_escaped, to_ansi_color}; -use crate::config::Config; pub trait Printer { fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;