mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-18 20:11:03 +00:00
Run cargo fmt
This commit is contained in:
parent
9b8ddb24d1
commit
a7338e2ea2
@ -1,9 +1,9 @@
|
|||||||
use bat::{
|
use bat::{
|
||||||
assets::HighlightingAssets,
|
assets::HighlightingAssets,
|
||||||
|
config::Config,
|
||||||
controller::Controller,
|
controller::Controller,
|
||||||
inputfile::InputFile,
|
inputfile::InputFile,
|
||||||
style::{OutputComponent, OutputComponents},
|
style::{OutputComponent, OutputComponents},
|
||||||
config::Config,
|
|
||||||
};
|
};
|
||||||
use console::Term;
|
use console::Term;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
@ -18,12 +18,12 @@ use ansi_term;
|
|||||||
|
|
||||||
use bat::{
|
use bat::{
|
||||||
assets::BAT_THEME_DEFAULT,
|
assets::BAT_THEME_DEFAULT,
|
||||||
|
config::{Config, PagingMode},
|
||||||
errors::*,
|
errors::*,
|
||||||
inputfile::InputFile,
|
inputfile::InputFile,
|
||||||
line_range::{HighlightedLineRanges, LineRange, LineRanges},
|
line_range::{HighlightedLineRanges, LineRange, LineRanges},
|
||||||
style::{OutputComponent, OutputComponents, OutputWrap},
|
style::{OutputComponent, OutputComponents, OutputWrap},
|
||||||
syntax_mapping::SyntaxMapping,
|
syntax_mapping::SyntaxMapping,
|
||||||
config::{Config, PagingMode},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn is_truecolor_terminal() -> bool {
|
fn is_truecolor_terminal() -> bool {
|
||||||
@ -201,14 +201,13 @@ impl App {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| String::from(BAT_THEME_DEFAULT)),
|
.unwrap_or_else(|| String::from(BAT_THEME_DEFAULT)),
|
||||||
line_ranges:
|
line_ranges: self
|
||||||
self.matches
|
.matches
|
||||||
.values_of("line-range")
|
.values_of("line-range")
|
||||||
.map(|vs| vs.map(LineRange::from).collect())
|
.map(|vs| vs.map(LineRange::from).collect())
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(LineRanges::from)
|
.map(LineRanges::from)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default(),
|
||||||
,
|
|
||||||
output_components,
|
output_components,
|
||||||
syntax_mapping,
|
syntax_mapping,
|
||||||
pager: self.matches.value_of("pager"),
|
pager: self.matches.value_of("pager"),
|
||||||
@ -216,14 +215,14 @@ impl App {
|
|||||||
Some("always") => true,
|
Some("always") => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
highlighted_lines:
|
highlighted_lines: self
|
||||||
self.matches
|
.matches
|
||||||
.values_of("highlight-line")
|
.values_of("highlight-line")
|
||||||
.map(|ws| ws.map(LineRange::from).collect())
|
.map(|ws| ws.map(LineRange::from).collect())
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(LineRanges::from)
|
.map(LineRanges::from)
|
||||||
.map(|lr| HighlightedLineRanges(lr))
|
.map(|lr| HighlightedLineRanges(lr))
|
||||||
.unwrap_or_default()
|
.unwrap_or_default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,5 +33,6 @@ pub fn clear_assets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn assets_from_cache_or_binary() -> HighlightingAssets {
|
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;
|
extern crate dirs as dirs_rs;
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
|
mod assets;
|
||||||
mod clap_app;
|
mod clap_app;
|
||||||
mod config;
|
mod config;
|
||||||
mod directories;
|
mod directories;
|
||||||
mod assets;
|
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
@ -23,22 +23,28 @@ use ansi_term::Colour::Green;
|
|||||||
use ansi_term::Style;
|
use ansi_term::Style;
|
||||||
|
|
||||||
use crate::{app::App, config::config_file};
|
use crate::{app::App, config::config_file};
|
||||||
use directories::PROJECT_DIRS;
|
use assets::{assets_from_cache_or_binary, cache_dir, clear_assets, config_dir};
|
||||||
use assets::{cache_dir, clear_assets, config_dir, assets_from_cache_or_binary};
|
|
||||||
use bat::controller::Controller;
|
use bat::controller::Controller;
|
||||||
|
use directories::PROJECT_DIRS;
|
||||||
|
|
||||||
use bat::{
|
use bat::{
|
||||||
assets::HighlightingAssets,
|
assets::HighlightingAssets,
|
||||||
|
config::Config,
|
||||||
errors::*,
|
errors::*,
|
||||||
inputfile::InputFile,
|
inputfile::InputFile,
|
||||||
style::{OutputComponent, OutputComponents},
|
style::{OutputComponent, OutputComponents},
|
||||||
config::Config,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
|
fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
|
||||||
if matches.is_present("build") {
|
if matches.is_present("build") {
|
||||||
let source_dir = matches.value_of("source").map(Path::new).unwrap_or_else(|| PROJECT_DIRS.config_dir());
|
let source_dir = matches
|
||||||
let target_dir = matches.value_of("target").map(Path::new).unwrap_or_else(|| PROJECT_DIRS.cache_dir());
|
.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");
|
let blank = matches.is_present("blank");
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ use std::io::{self, Write};
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::assets::HighlightingAssets;
|
use crate::assets::HighlightingAssets;
|
||||||
|
use crate::config::{Config, PagingMode};
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::inputfile::{InputFile, InputFileReader};
|
use crate::inputfile::{InputFile, InputFileReader};
|
||||||
use crate::line_range::{LineRanges, RangeCheckResult};
|
use crate::line_range::{LineRanges, RangeCheckResult};
|
||||||
use crate::output::OutputType;
|
use crate::output::OutputType;
|
||||||
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
||||||
use crate::config::{Config, PagingMode};
|
|
||||||
|
|
||||||
pub struct Controller<'a> {
|
pub struct Controller<'a> {
|
||||||
config: &'a Config<'a>,
|
config: &'a Config<'a>,
|
||||||
|
@ -159,7 +159,6 @@ impl Default for HighlightedLineRanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn ranges(rs: &[&str]) -> LineRanges {
|
fn ranges(rs: &[&str]) -> LineRanges {
|
||||||
LineRanges::from(rs.iter().map(|r| LineRange::from(r).unwrap()).collect())
|
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 shell_words;
|
||||||
|
|
||||||
|
use crate::config::PagingMode;
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::less::retrieve_less_version;
|
use crate::less::retrieve_less_version;
|
||||||
use crate::config::PagingMode;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum OutputType {
|
pub enum OutputType {
|
||||||
|
@ -20,6 +20,7 @@ use encoding::{DecoderTrap, Encoding};
|
|||||||
use unicode_width::UnicodeWidthChar;
|
use unicode_width::UnicodeWidthChar;
|
||||||
|
|
||||||
use crate::assets::HighlightingAssets;
|
use crate::assets::HighlightingAssets;
|
||||||
|
use crate::config::Config;
|
||||||
use crate::decorations::{
|
use crate::decorations::{
|
||||||
Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration,
|
Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration,
|
||||||
};
|
};
|
||||||
@ -31,7 +32,6 @@ use crate::line_range::RangeCheckResult;
|
|||||||
use crate::preprocessor::{expand_tabs, replace_nonprintable};
|
use crate::preprocessor::{expand_tabs, replace_nonprintable};
|
||||||
use crate::style::OutputWrap;
|
use crate::style::OutputWrap;
|
||||||
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
||||||
use crate::config::Config;
|
|
||||||
|
|
||||||
pub trait Printer {
|
pub trait Printer {
|
||||||
fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
|
fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user