on master help sign in
Run cargo fmt
commita7338e2ea2b6fd548c2d896c0224cb3f3d44d91a authorsharkdp <davidpeter@web.de> dateSat 21 Mar 2020, 19:40 (7 years ago) parent9b8ddb2
8 files changed+34−29
examples/simple.rs+1−1 src/bin/bat/app.rs+16−17 src/bin/bat/assets.rs+2−1 src/bin/bat/main.rs+12−6 src/controller.rs+1−1 src/line_range.rs−1 src/output.rs+1−1 src/printer.rs+1−1
examples/simple.rs+1−1
@@ -1,9 +1,9 @@
11use bat::{
22 assets::HighlightingAssets,
3+ config::Config,
34 controller::Controller,
45 inputfile::InputFile,
56 style::{OutputComponent, OutputComponents},
6− config::Config,
77};
88use console::Term;
99use std::process;
src/bin/bat/app.rs+16−17
@@ -18,12 +18,12 @@ use ansi_term;
1818
1919use bat::{
2020 assets::BAT_THEME_DEFAULT,
21+ config::{Config, PagingMode},
2122 errors::*,
2223 inputfile::InputFile,
2324 line_range::{HighlightedLineRanges, LineRange, LineRanges},
2425 style::{OutputComponent, OutputComponents, OutputWrap},
2526 syntax_mapping::SyntaxMapping,
26− config::{Config, PagingMode},
2727};
2828
2929fn is_truecolor_terminal() -> bool {
@@ -201,14 +201,13 @@ impl App {
201201 }
202202 })
203203 .unwrap_or_else(|| String::from(BAT_THEME_DEFAULT)),
204− line_ranges:
205− self.matches
206− .values_of("line-range")
207− .map(|vs| vs.map(LineRange::from).collect())
208− .transpose()?
209− .map(LineRanges::from)
210− .unwrap_or_default()
211− ,
204+ line_ranges: self
205+ .matches
206+ .values_of("line-range")
207+ .map(|vs| vs.map(LineRange::from).collect())
208+ .transpose()?
209+ .map(LineRanges::from)
210+ .unwrap_or_default(),
212211 output_components,
213212 syntax_mapping,
214213 pager: self.matches.value_of("pager"),
@@ -216,14 +215,14 @@ impl App {
216215 Some("always") => true,
217216 _ => false,
218217 },
219− highlighted_lines:
220− self.matches
221− .values_of("highlight-line")
222− .map(|ws| ws.map(LineRange::from).collect())
223− .transpose()?
224− .map(LineRanges::from)
225− .map(|lr| HighlightedLineRanges(lr))
226− .unwrap_or_default()
218+ highlighted_lines: self
219+ .matches
220+ .values_of("highlight-line")
221+ .map(|ws| ws.map(LineRange::from).collect())
222+ .transpose()?
223+ .map(LineRanges::from)
224+ .map(|lr| HighlightedLineRanges(lr))
225+ .unwrap_or_default(),
227226 })
228227 }
229228
src/bin/bat/assets.rs+2−1
@@ -33,5 +33,6 @@ pub fn clear_assets() {
3333}
3434
3535pub fn assets_from_cache_or_binary() -> HighlightingAssets {
36− HighlightingAssets::from_cache(&theme_set_path(), &syntax_set_path()).unwrap_or(HighlightingAssets::from_binary())
36+ HighlightingAssets::from_cache(&theme_set_path(), &syntax_set_path())
37+ .unwrap_or(HighlightingAssets::from_binary())
3738}
src/bin/bat/main.rs+12−6
@@ -7,10 +7,10 @@ extern crate clap;
77extern crate dirs as dirs_rs;
88
99mod app;
10+mod assets;
1011mod clap_app;
1112mod config;
1213mod directories;
13−mod assets;
1414
1515use std::collections::HashSet;
1616use std::ffi::OsStr;
@@ -23,22 +23,28 @@ use ansi_term::Colour::Green;
2323use ansi_term::Style;
2424
2525use crate::{app::App, config::config_file};
26−use directories::PROJECT_DIRS;
27−use assets::{cache_dir, clear_assets, config_dir, assets_from_cache_or_binary};
26+use assets::{assets_from_cache_or_binary, cache_dir, clear_assets, config_dir};
2827use bat::controller::Controller;
28+use directories::PROJECT_DIRS;
2929
3030use bat::{
3131 assets::HighlightingAssets,
32+ config::Config,
3233 errors::*,
3334 inputfile::InputFile,
3435 style::{OutputComponent, OutputComponents},
35− config::Config,
3636};
3737
3838fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
3939 if matches.is_present("build") {
40− let source_dir = matches.value_of("source").map(Path::new).unwrap_or_else(|| PROJECT_DIRS.config_dir());
41− let target_dir = matches.value_of("target").map(Path::new).unwrap_or_else(|| PROJECT_DIRS.cache_dir());
40+ let source_dir = matches
41+ .value_of("source")
42+ .map(Path::new)
43+ .unwrap_or_else(|| PROJECT_DIRS.config_dir());
44+ let target_dir = matches
45+ .value_of("target")
46+ .map(Path::new)
47+ .unwrap_or_else(|| PROJECT_DIRS.cache_dir());
4248
4349 let blank = matches.is_present("blank");
4450
src/controller.rs+1−1
@@ -2,12 +2,12 @@ use std::io::{self, Write};
22use std::path::Path;
33
44use crate::assets::HighlightingAssets;
5+use crate::config::{Config, PagingMode};
56use crate::errors::*;
67use crate::inputfile::{InputFile, InputFileReader};
78use crate::line_range::{LineRanges, RangeCheckResult};
89use crate::output::OutputType;
910use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
10−use crate::config::{Config, PagingMode};
1111
1212pub struct Controller<'a> {
1313 config: &'a Config<'a>,
src/line_range.rs−1
@@ -159,7 +159,6 @@ impl Default for HighlightedLineRanges {
159159 }
160160}
161161
162−
163162#[cfg(test)]
164163fn ranges(rs: &[&str]) -> LineRanges {
165164 LineRanges::from(rs.iter().map(|r| LineRange::from(r).unwrap()).collect())
src/output.rs+1−1
@@ -6,9 +6,9 @@ use std::process::{Child, Command, Stdio};
66
77use shell_words;
88
9+use crate::config::PagingMode;
910use crate::errors::*;
1011use crate::less::retrieve_less_version;
11−use crate::config::PagingMode;
1212
1313#[derive(Debug)]
1414pub enum OutputType {
src/printer.rs+1−1
@@ -20,6 +20,7 @@ use encoding::{DecoderTrap, Encoding};
2020use unicode_width::UnicodeWidthChar;
2121
2222use crate::assets::HighlightingAssets;
23+use crate::config::Config;
2324use crate::decorations::{
2425 Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration,
2526};
@@ -31,7 +32,6 @@ use crate::line_range::RangeCheckResult;
3132use crate::preprocessor::{expand_tabs, replace_nonprintable};
3233use crate::style::OutputWrap;
3334use crate::terminal::{as_terminal_escaped, to_ansi_color};
34−use crate::config::Config;
3535
3636pub trait Printer {
3737 fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;