mirror of
https://github.com/sharkdp/bat
synced 2024-11-15 08:37:12 +00:00
Run cargo fmt
This commit is contained in:
parent
9b8ddb24d1
commit
a7338e2ea2
8 changed files with 34 additions and 29 deletions
|
@ -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;
|
||||
|
|
|
@ -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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<()>;
|
||||
|
|
Loading…
Reference in a new issue