on master help sign in
Migrated to Rust 2018
a21ae61Daniele Esposti
Cargo.toml+1
@@ -13,6 +13,7 @@ exclude = [
13 "assets/themes/*",
13 "assets/themes/*",
14]
14]
15build = "build.rs"
15build = "build.rs"
16+edition = '2018'
16
17
17[dependencies]
18[dependencies]
18atty = "0.2.2"
19atty = "0.2.2"
src/app.rs+9−9
@@ -5,7 +5,7 @@ use std::str::FromStr;
5use atty::{self, Stream};
5use atty::{self, Stream};
6
6
7use clap::ArgMatches;
7use clap::ArgMatches;
8−use clap_app;
8+use crate::clap_app;
9use wild;
9use wild;
10
10
11use console::Term;
11use console::Term;
@@ -13,14 +13,14 @@ use console::Term;
13#[cfg(windows)]
13#[cfg(windows)]
14use ansi_term;
14use ansi_term;
15
15
16−use assets::BAT_THEME_DEFAULT;
16+use crate::assets::BAT_THEME_DEFAULT;
17−use config::{get_args_from_config_file, get_args_from_env_var};
17+use crate::config::{get_args_from_config_file, get_args_from_env_var};
18−use errors::*;
18+use crate::errors::*;
19−use inputfile::InputFile;
19+use crate::inputfile::InputFile;
20−use line_range::{LineRange, LineRanges};
20+use crate::line_range::{LineRange, LineRanges};
21−use style::{OutputComponent, OutputComponents, OutputWrap};
21+use crate::style::{OutputComponent, OutputComponents, OutputWrap};
22−use syntax_mapping::SyntaxMapping;
22+use crate::syntax_mapping::SyntaxMapping;
23−use util::transpose;
23+use crate::util::transpose;
24
24
25#[derive(Debug, Clone, Copy, PartialEq)]
25#[derive(Debug, Clone, Copy, PartialEq)]
26pub enum PagingMode {
26pub enum PagingMode {
src/assets.rs+4−4
@@ -8,11 +8,11 @@ use syntect::dumps::{dump_to_file, from_binary, from_reader};
8use syntect::highlighting::{Theme, ThemeSet};
8use syntect::highlighting::{Theme, ThemeSet};
9use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
9use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
10
10
11−use dirs::PROJECT_DIRS;
11+use crate::dirs::PROJECT_DIRS;
12
12
13−use errors::*;
13+use crate::errors::*;
14−use inputfile::{InputFile, InputFileReader};
14+use crate::inputfile::{InputFile, InputFileReader};
15−use syntax_mapping::SyntaxMapping;
15+use crate::syntax_mapping::SyntaxMapping;
16
16
17pub const BAT_THEME_DEFAULT: &str = "Monokai Extended";
17pub const BAT_THEME_DEFAULT: &str = "Monokai Extended";
18
18
src/config.rs+2−2
@@ -5,8 +5,8 @@ use std::path::PathBuf;
5
5
6use shell_words;
6use shell_words;
7
7
8−use dirs::PROJECT_DIRS;
8+use crate::dirs::PROJECT_DIRS;
9−use util::transpose;
9+use crate::util::transpose;
10
10
11pub fn config_file() -> PathBuf {
11pub fn config_file() -> PathBuf {
12 env::var("BAT_CONFIG_PATH")
12 env::var("BAT_CONFIG_PATH")
src/controller.rs+7−7
@@ -1,13 +1,13 @@
1use std::io::{self, Write};
1use std::io::{self, Write};
2use std::path::Path;
2use std::path::Path;
3
3
4−use app::{Config, PagingMode};
4+use crate::app::{Config, PagingMode};
5−use assets::HighlightingAssets;
5+use crate::assets::HighlightingAssets;
6−use errors::*;
6+use crate::errors::*;
7−use inputfile::{InputFile, InputFileReader};
7+use crate::inputfile::{InputFile, InputFileReader};
8−use line_range::{LineRanges, RangeCheckResult};
8+use crate::line_range::{LineRanges, RangeCheckResult};
9−use output::OutputType;
9+use crate::output::OutputType;
10−use printer::{InteractivePrinter, Printer, SimplePrinter};
10+use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
11
11
12pub struct Controller<'a> {
12pub struct Controller<'a> {
13 config: &'a Config<'a>,
13 config: &'a Config<'a>,
src/decorations.rs+2−2
@@ -1,6 +1,6 @@
1use ansi_term::Style;
1use ansi_term::Style;
2−use diff::LineChange;
2+use crate::diff::LineChange;
3−use printer::{Colors, InteractivePrinter};
3+use crate::printer::{Colors, InteractivePrinter};
4
4
5#[derive(Clone)]
5#[derive(Clone)]
6pub struct DecorationText {
6pub struct DecorationText {
src/dirs.rs+1−1
@@ -1,4 +1,4 @@
1−use dirs_rs;
1+use crate::dirs_rs;
2use std::path::{Path, PathBuf};
2use std::path::{Path, PathBuf};
3
3
4#[cfg(target_os = "macos")]
4#[cfg(target_os = "macos")]
src/inputfile.rs+1−1
@@ -3,7 +3,7 @@ use std::io::{self, BufRead, BufReader};
3
3
4use content_inspector::{self, ContentType};
4use content_inspector::{self, ContentType};
5
5
6−use errors::*;
6+use crate::errors::*;
7
7
8const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs");
8const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs");
9
9
src/line_range.rs+1−1
@@ -1,4 +1,4 @@
1−use errors::*;
1+use crate::errors::*;
2
2
3#[derive(Clone)]
3#[derive(Clone)]
4pub struct LineRange {
4pub struct LineRange {
src/main.rs+7−7
@@ -48,12 +48,12 @@ use std::process;
48use ansi_term::Colour::Green;
48use ansi_term::Colour::Green;
49use ansi_term::Style;
49use ansi_term::Style;
50
50
51−use app::{App, Config};
51+use crate::app::{App, Config};
52−use assets::{cache_dir, clear_assets, config_dir, HighlightingAssets};
52+use crate::assets::{cache_dir, clear_assets, config_dir, HighlightingAssets};
53−use config::config_file;
53+use crate::config::config_file;
54−use controller::Controller;
54+use crate::controller::Controller;
55−use inputfile::InputFile;
55+use crate::inputfile::InputFile;
56−use style::{OutputComponent, OutputComponents};
56+use crate::style::{OutputComponent, OutputComponents};
57
57
58mod errors {
58mod errors {
59 error_chain! {
59 error_chain! {
@@ -80,7 +80,7 @@ mod errors {
80 }
80 }
81}
81}
82
82
83−use errors::*;
83+use crate::errors::*;
84
84
85fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
85fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
86 if matches.is_present("build") {
86 if matches.is_present("build") {
src/output.rs+2−2
@@ -6,8 +6,8 @@ use std::process::{Child, Command, Stdio};
6
6
7use shell_words;
7use shell_words;
8
8
9−use app::PagingMode;
9+use crate::app::PagingMode;
10−use errors::*;
10+use crate::errors::*;
11
11
12pub enum OutputType {
12pub enum OutputType {
13 Pager(Child),
13 Pager(Child),
src/printer.rs+10−10
@@ -16,16 +16,16 @@ 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 app::Config;
19+use crate::app::Config;
20−use assets::HighlightingAssets;
20+use crate::assets::HighlightingAssets;
21−use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
21+use crate::decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
22−use diff::get_git_diff;
22+use crate::diff::get_git_diff;
23−use diff::LineChanges;
23+use crate::diff::LineChanges;
24−use errors::*;
24+use crate::errors::*;
25−use inputfile::{InputFile, InputFileReader};
25+use crate::inputfile::{InputFile, InputFileReader};
26−use preprocessor::{expand_tabs, replace_nonprintable};
26+use crate::preprocessor::{expand_tabs, replace_nonprintable};
27−use style::OutputWrap;
27+use crate::style::OutputWrap;
28−use terminal::{as_terminal_escaped, to_ansi_color};
28+use crate::terminal::{as_terminal_escaped, to_ansi_color};
29
29
30pub trait Printer {
30pub trait Printer {
31 fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
31 fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
src/style.rs+1−1
@@ -1,7 +1,7 @@
1use std::collections::HashSet;
1use std::collections::HashSet;
2use std::str::FromStr;
2use std::str::FromStr;
3
3
4−use errors::*;
4+use crate::errors::*;
5
5
6#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
6#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
7pub enum OutputComponent {
7pub enum OutputComponent {
tests/snapshot_tests.rs+1−1
@@ -1,6 +1,6 @@
1mod tester;
1mod tester;
2
2
3−use tester::BatTester;
3+use crate::tester::BatTester;
4
4
5macro_rules! snapshot_tests {
5macro_rules! snapshot_tests {
6 ($($test_name: ident: $style: expr,)*) => {
6 ($($test_name: ident: $style: expr,)*) => {