@@ -1,9 +1,6 @@
11// `error_chain!` can recurse deeply
22#![recursion_limit = "1024"]
33
4−#[macro_use]
5−extern crate error_chain;
6−
74extern crate ansi_term;
85extern crate atty;
96extern crate console;
@@ -19,6 +16,7 @@ pub mod assets;
1916pub mod controller;
2017mod decorations;
2118mod diff;
19+pub mod errors;
2220pub mod inputfile;
2321mod less;
2422pub mod line_range;
@@ -29,31 +27,6 @@ pub mod style;
2927pub mod syntax_mapping;
3028mod terminal;
3129
32−pub mod errors {
33− error_chain! {
34− foreign_links {
35− Clap(::clap::Error);
36− Io(::std::io::Error);
37− SyntectError(::syntect::LoadingError);
38− ParseIntError(::std::num::ParseIntError);
39− }
40− }
41−
42− pub fn handle_error(error: &Error) {
43− match error {
44− Error(ErrorKind::Io(ref io_error), _)
45− if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
46− {
47− ::std::process::exit(0);
48− }
49− _ => {
50− use ansi_term::Colour::Red;
51− eprintln!("{}: {}", Red.paint("[bat error]"), error);
52− }
53− };
54− }
55−}
56−
5730#[derive(Debug, Clone, Copy, PartialEq)]
5831pub enum PagingMode {
5932 Always,
@@ -68,7 +41,7 @@ impl Default for PagingMode {
6841}
6942
7043use inputfile::InputFile;
71−use line_range::{LineRanges, HighlightedLineRanges};
44+use line_range::{HighlightedLineRanges, LineRanges};
7245use style::{OutputComponents, OutputWrap};
7346use syntax_mapping::SyntaxMapping;
7447
@@ -131,12 +104,18 @@ pub struct Config<'a> {
131104fn default_config_should_include_all_lines() {
132105 use line_range::RangeCheckResult;
133106
134− assert_eq!(Config::default().line_ranges.check(17), RangeCheckResult::InRange);
107+ assert_eq!(
108+ Config::default().line_ranges.check(17),
109+ RangeCheckResult::InRange
110+ );
135111}
136112
137113#[test]
138114fn default_config_should_highlight_no_lines() {
139115 use line_range::RangeCheckResult;
140116
141− assert_ne!(Config::default().highlighted_lines.0.check(17), RangeCheckResult::InRange);
117+ assert_ne!(
118+ Config::default().highlighted_lines.0.check(17),
119+ RangeCheckResult::InRange
120+ );
142121}