on master help sign in
Fix all compile errors in bin/bat ➕
23d80f9Fahmi Akbar Wildana
src/bin/bat/app.rs+10−8
@@ -13,14 +13,16 @@ use console::Term;
13#[cfg(windows)]
13#[cfg(windows)]
14use ansi_term;
14use ansi_term;
15
15
16+use bat::{
16−use crate::assets::BAT_THEME_DEFAULT;
17+ assets::BAT_THEME_DEFAULT,
17−use crate::config::{get_args_from_config_file, get_args_from_env_var};
18+ config::{get_args_from_config_file, get_args_from_env_var},
18−use crate::errors::*;
19+ errors::*,
19−use crate::inputfile::InputFile;
20+ inputfile::InputFile,
20−use crate::line_range::{LineRange, LineRanges};
21+ line_range::{LineRange, LineRanges},
21−use crate::style::{OutputComponent, OutputComponents, OutputWrap};
22+ style::{OutputComponent, OutputComponents, OutputWrap},
22−use crate::syntax_mapping::SyntaxMapping;
23+ syntax_mapping::SyntaxMapping,
23−use crate::util::transpose;
24+ util::transpose,
25+};
24
26
25#[derive(Debug, Clone, Copy, PartialEq)]
27#[derive(Debug, Clone, Copy, PartialEq)]
26pub enum PagingMode {
28pub enum PagingMode {
src/bin/bat/controller.rs+12−7
@@ -1,13 +1,18 @@
1use std::io::{self, Write};
1use std::io::{self, Write};
2use std::path::Path;
2use std::path::Path;
3
3
4+use crate::{
4−use crate::app::{Config, PagingMode};
5+ app::{Config, PagingMode},
6+ output::OutputType,
7+ printer::{InteractivePrinter, Printer, SimplePrinter},
8+};
9+
10+use bat::{
5−use crate::assets::HighlightingAssets;
11+ assets::HighlightingAssets,
6−use crate::errors::*;
12+ errors::*,
7−use crate::inputfile::{InputFile, InputFileReader};
13+ inputfile::{InputFile, InputFileReader},
8−use crate::line_range::{LineRanges, RangeCheckResult};
14+ line_range::{LineRanges, RangeCheckResult},
9−use crate::output::OutputType;
15+};
10−use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
11
16
12pub struct Controller<'a> {
17pub struct Controller<'a> {
13 config: &'a Config<'a>,
18 config: &'a Config<'a>,
src/bin/bat/decorations.rs+1−1
@@ -1,4 +1,4 @@
1−use crate::diff::LineChange;
1+use bat::diff::LineChange;
2use crate::printer::{Colors, InteractivePrinter};
2use crate::printer::{Colors, InteractivePrinter};
3use ansi_term::Style;
3use ansi_term::Style;
4
4
src/bin/bat/main.rs+12−44
@@ -22,22 +22,11 @@ extern crate syntect;
22extern crate wild;
22extern crate wild;
23
23
24mod app;
24mod app;
25−mod assets;
26mod clap_app;
25mod clap_app;
27−mod config;
28mod controller;
26mod controller;
29mod decorations;
27mod decorations;
30−mod diff;
31−mod dirs;
32−mod inputfile;
33−mod line_range;
34mod output;
28mod output;
35−mod preprocessor;
36mod printer;
29mod printer;
37−mod style;
38−mod syntax_mapping;
39−mod terminal;
40−mod util;
41
30
42use std::collections::HashSet;
31use std::collections::HashSet;
43use std::io;
32use std::io;
@@ -48,39 +37,18 @@ use std::process;
48use ansi_term::Colour::Green;
37use ansi_term::Colour::Green;
49use ansi_term::Style;
38use ansi_term::Style;
50
39
40+use crate::{
51−use crate::app::{App, Config};
41+ app::{App, Config},
42+ controller::Controller,
43+};
44+
45+use bat::{
52−use crate::assets::{cache_dir, clear_assets, config_dir, HighlightingAssets};
46+ assets::{cache_dir, clear_assets, config_dir, HighlightingAssets},
53−use crate::config::config_file;
47+ config::config_file,
54−use crate::controller::Controller;
48+ errors::*,
55−use crate::inputfile::InputFile;
49+ inputfile::InputFile,
56−use crate::style::{OutputComponent, OutputComponents};
50+ style::{OutputComponent, OutputComponents},
57−
51+};
58−mod errors {
59− error_chain! {
60− foreign_links {
61− Clap(::clap::Error);
62− Io(::std::io::Error);
63− SyntectError(::syntect::LoadingError);
64− ParseIntError(::std::num::ParseIntError);
65− }
66− }
67−
68− pub fn handle_error(error: &Error) {
69− match error {
70− Error(ErrorKind::Io(ref io_error), _)
71− if io_error.kind() == super::io::ErrorKind::BrokenPipe =>
72− {
73− super::process::exit(0);
74− }
75− _ => {
76− use ansi_term::Colour::Red;
77− eprintln!("{}: {}", Red.paint("[bat error]"), error);
78− }
79− };
80− }
81−}
82−
83−use crate::errors::*;
84
52
85fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
53fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
86 if matches.is_present("build") {
54 if matches.is_present("build") {
src/bin/bat/output.rs+1−1
@@ -7,7 +7,7 @@ use std::process::{Child, Command, Stdio};
7use shell_words;
7use shell_words;
8
8
9use crate::app::PagingMode;
9use crate::app::PagingMode;
10−use crate::errors::*;
10+use bat::errors::*;
11
11
12pub enum OutputType {
12pub enum OutputType {
13 Pager(Child),
13 Pager(Child),
src/bin/bat/printer.rs+14−11
@@ -16,18 +16,21 @@ use content_inspector::ContentType;
16use encoding::all::{UTF_16BE, UTF_16LE};
16use encoding::all::{UTF_16BE, UTF_16LE};
17use encoding::{DecoderTrap, Encoding};
17use encoding::{DecoderTrap, Encoding};
18
18
19+use crate::{
19−use crate::app::Config;
20+ app::Config,
20−use crate::assets::HighlightingAssets;
21−use crate::decorations::{
22− Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration,
21+ decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration},
22+};
23+
24+use bat::{
25+ assets::HighlightingAssets,
26+ diff::get_git_diff,
27+ diff::LineChanges,
28+ errors::*,
29+ inputfile::{InputFile, InputFileReader},
30+ preprocessor::{expand_tabs, replace_nonprintable},
31+ style::OutputWrap,
32+ terminal::{as_terminal_escaped, to_ansi_color},
23};
33};
24−use crate::diff::get_git_diff;
25−use crate::diff::LineChanges;
26−use crate::errors::*;
27−use crate::inputfile::{InputFile, InputFileReader};
28−use crate::preprocessor::{expand_tabs, replace_nonprintable};
29−use crate::style::OutputWrap;
30−use crate::terminal::{as_terminal_escaped, to_ansi_color};
31
34
32pub trait Printer {
35pub trait Printer {
33 fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
36 fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
src/lib.rs+15−1
@@ -30,7 +30,7 @@ pub mod syntax_mapping;
30pub mod terminal;
30pub mod terminal;
31pub mod util;
31pub mod util;
32
32
33−mod errors {
33+pub mod errors {
34 error_chain! {
34 error_chain! {
35 foreign_links {
35 foreign_links {
36 Clap(::clap::Error);
36 Clap(::clap::Error);
@@ -39,4 +39,18 @@ mod errors {
39 ParseIntError(::std::num::ParseIntError);
39 ParseIntError(::std::num::ParseIntError);
40 }
40 }
41 }
41 }
42+
43+ pub fn handle_error(error: &Error) {
44+ match error {
45+ Error(ErrorKind::Io(ref io_error), _)
46+ if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
47+ {
48+ ::std::process::exit(0);
49+ }
50+ _ => {
51+ use ansi_term::Colour::Red;
52+ eprintln!("{}: {}", Red.paint("[bat error]"), error);
53+ }
54+ };
55+ }
42}
56}