1// `error_chain!` can recurse deeply
2#![recursion_limit = "1024"]
5extern crate error_chain;
8extern crate lazy_static;
10extern crate ansi_term;
13extern crate content_inspector;
14extern crate dirs as dirs_rs;
17extern crate shell_words;
32pub mod syntax_mapping;
40 SyntectError(::syntect::LoadingError);
41 ParseIntError(::std::num::ParseIntError);
45 pub fn handle_error(error: &Error) {
47 Error(ErrorKind::Io(ref io_error), _)
48 if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
50 ::std::process::exit(0);
53 use ansi_term::Colour::Red;
54 eprintln!("{}: {}", Red.paint("[bat error]"), error);
60#[derive(Debug, Clone, Copy, PartialEq)]
67impl Default for PagingMode {
68 fn default() -> Self {
73use inputfile::InputFile;
74use line_range::LineRanges;
75use style::{OutputComponents, OutputWrap};
76use syntax_mapping::SyntaxMapping;
78#[derive(Debug, Clone, Default)]
79pub struct Config<'a> {
80 /// List of files to print
81 pub files: Vec<InputFile<'a>>,
83 /// The explicitly configured language, if any
84 pub language: Option<&'a str>,
86 /// Whether or not to show/replace non-printable characters like space, tab and newline.
87 pub show_nonprintable: bool,
89 /// The character width of the terminal
90 pub term_width: usize,
92 /// The width of tab characters.
93 /// Currently, a value of 0 will cause tabs to be passed through without expanding them.
96 /// Whether or not to simply loop through all input (`cat` mode)
97 pub loop_through: bool,
99 /// Whether or not the output should be colorized
100 pub colored_output: bool,
102 /// Whether or not the output terminal supports true color
103 pub true_color: bool,
105 /// Style elements (grid, line numbers, ...)
106 pub output_components: OutputComponents,
108 /// Text wrapping mode
109 pub output_wrap: OutputWrap,
112 pub paging_mode: PagingMode,
114 /// Specifies the lines that should be printed
115 pub line_ranges: LineRanges,
117 /// The syntax highlighting theme
120 /// File extension/name mappings
121 pub syntax_mapping: SyntaxMapping,
123 /// Command to start the pager
124 pub pager: Option<&'a str>,
126 /// Whether or not to use ANSI italics
127 pub use_italic_text: bool,
129 /// Lines to highlight
130 pub highlight_lines: Vec<usize>,
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list