mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-18 10:41:05 +01:00
Migrated to Rust 2018
This commit is contained in:
parent
b94c94e845
commit
a21ae614e6
@ -13,6 +13,7 @@ exclude = [
|
|||||||
"assets/themes/*",
|
"assets/themes/*",
|
||||||
]
|
]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
edition = '2018'
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
atty = "0.2.2"
|
atty = "0.2.2"
|
||||||
|
18
src/app.rs
18
src/app.rs
@ -5,7 +5,7 @@ use std::str::FromStr;
|
|||||||
use atty::{self, Stream};
|
use atty::{self, Stream};
|
||||||
|
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use clap_app;
|
use crate::clap_app;
|
||||||
use wild;
|
use wild;
|
||||||
|
|
||||||
use console::Term;
|
use console::Term;
|
||||||
@ -13,14 +13,14 @@ use console::Term;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use ansi_term;
|
use ansi_term;
|
||||||
|
|
||||||
use assets::BAT_THEME_DEFAULT;
|
use crate::assets::BAT_THEME_DEFAULT;
|
||||||
use config::{get_args_from_config_file, get_args_from_env_var};
|
use crate::config::{get_args_from_config_file, get_args_from_env_var};
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
use inputfile::InputFile;
|
use crate::inputfile::InputFile;
|
||||||
use line_range::{LineRange, LineRanges};
|
use crate::line_range::{LineRange, LineRanges};
|
||||||
use style::{OutputComponent, OutputComponents, OutputWrap};
|
use crate::style::{OutputComponent, OutputComponents, OutputWrap};
|
||||||
use syntax_mapping::SyntaxMapping;
|
use crate::syntax_mapping::SyntaxMapping;
|
||||||
use util::transpose;
|
use crate::util::transpose;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum PagingMode {
|
pub enum PagingMode {
|
||||||
|
@ -8,11 +8,11 @@ use syntect::dumps::{dump_to_file, from_binary, from_reader};
|
|||||||
use syntect::highlighting::{Theme, ThemeSet};
|
use syntect::highlighting::{Theme, ThemeSet};
|
||||||
use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
|
use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
|
||||||
|
|
||||||
use dirs::PROJECT_DIRS;
|
use crate::dirs::PROJECT_DIRS;
|
||||||
|
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
use inputfile::{InputFile, InputFileReader};
|
use crate::inputfile::{InputFile, InputFileReader};
|
||||||
use syntax_mapping::SyntaxMapping;
|
use crate::syntax_mapping::SyntaxMapping;
|
||||||
|
|
||||||
pub const BAT_THEME_DEFAULT: &str = "Monokai Extended";
|
pub const BAT_THEME_DEFAULT: &str = "Monokai Extended";
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
use shell_words;
|
use shell_words;
|
||||||
|
|
||||||
use dirs::PROJECT_DIRS;
|
use crate::dirs::PROJECT_DIRS;
|
||||||
use util::transpose;
|
use crate::util::transpose;
|
||||||
|
|
||||||
pub fn config_file() -> PathBuf {
|
pub fn config_file() -> PathBuf {
|
||||||
env::var("BAT_CONFIG_PATH")
|
env::var("BAT_CONFIG_PATH")
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use app::{Config, PagingMode};
|
use crate::app::{Config, PagingMode};
|
||||||
use assets::HighlightingAssets;
|
use crate::assets::HighlightingAssets;
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
use inputfile::{InputFile, InputFileReader};
|
use crate::inputfile::{InputFile, InputFileReader};
|
||||||
use line_range::{LineRanges, RangeCheckResult};
|
use crate::line_range::{LineRanges, RangeCheckResult};
|
||||||
use output::OutputType;
|
use crate::output::OutputType;
|
||||||
use printer::{InteractivePrinter, Printer, SimplePrinter};
|
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
||||||
|
|
||||||
pub struct Controller<'a> {
|
pub struct Controller<'a> {
|
||||||
config: &'a Config<'a>,
|
config: &'a Config<'a>,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use ansi_term::Style;
|
use ansi_term::Style;
|
||||||
use diff::LineChange;
|
use crate::diff::LineChange;
|
||||||
use printer::{Colors, InteractivePrinter};
|
use crate::printer::{Colors, InteractivePrinter};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DecorationText {
|
pub struct DecorationText {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use dirs_rs;
|
use crate::dirs_rs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -3,7 +3,7 @@ use std::io::{self, BufRead, BufReader};
|
|||||||
|
|
||||||
use content_inspector::{self, ContentType};
|
use content_inspector::{self, ContentType};
|
||||||
|
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs");
|
const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs");
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LineRange {
|
pub struct LineRange {
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -48,12 +48,12 @@ use std::process;
|
|||||||
use ansi_term::Colour::Green;
|
use ansi_term::Colour::Green;
|
||||||
use ansi_term::Style;
|
use ansi_term::Style;
|
||||||
|
|
||||||
use app::{App, Config};
|
use crate::app::{App, Config};
|
||||||
use assets::{cache_dir, clear_assets, config_dir, HighlightingAssets};
|
use crate::assets::{cache_dir, clear_assets, config_dir, HighlightingAssets};
|
||||||
use config::config_file;
|
use crate::config::config_file;
|
||||||
use controller::Controller;
|
use crate::controller::Controller;
|
||||||
use inputfile::InputFile;
|
use crate::inputfile::InputFile;
|
||||||
use style::{OutputComponent, OutputComponents};
|
use crate::style::{OutputComponent, OutputComponents};
|
||||||
|
|
||||||
mod errors {
|
mod errors {
|
||||||
error_chain! {
|
error_chain! {
|
||||||
@ -80,7 +80,7 @@ mod errors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
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") {
|
||||||
|
@ -6,8 +6,8 @@ use std::process::{Child, Command, Stdio};
|
|||||||
|
|
||||||
use shell_words;
|
use shell_words;
|
||||||
|
|
||||||
use app::PagingMode;
|
use crate::app::PagingMode;
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
pub enum OutputType {
|
pub enum OutputType {
|
||||||
Pager(Child),
|
Pager(Child),
|
||||||
|
@ -16,16 +16,16 @@ use content_inspector::ContentType;
|
|||||||
use encoding::all::{UTF_16BE, UTF_16LE};
|
use encoding::all::{UTF_16BE, UTF_16LE};
|
||||||
use encoding::{DecoderTrap, Encoding};
|
use encoding::{DecoderTrap, Encoding};
|
||||||
|
|
||||||
use app::Config;
|
use crate::app::Config;
|
||||||
use assets::HighlightingAssets;
|
use crate::assets::HighlightingAssets;
|
||||||
use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
|
use crate::decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
|
||||||
use diff::get_git_diff;
|
use crate::diff::get_git_diff;
|
||||||
use diff::LineChanges;
|
use crate::diff::LineChanges;
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
use inputfile::{InputFile, InputFileReader};
|
use crate::inputfile::{InputFile, InputFileReader};
|
||||||
use preprocessor::{expand_tabs, replace_nonprintable};
|
use crate::preprocessor::{expand_tabs, replace_nonprintable};
|
||||||
use style::OutputWrap;
|
use crate::style::OutputWrap;
|
||||||
use terminal::{as_terminal_escaped, to_ansi_color};
|
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
||||||
|
|
||||||
pub trait Printer {
|
pub trait Printer {
|
||||||
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
|
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
|
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
|
||||||
pub enum OutputComponent {
|
pub enum OutputComponent {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
mod tester;
|
mod tester;
|
||||||
|
|
||||||
use tester::BatTester;
|
use crate::tester::BatTester;
|
||||||
|
|
||||||
macro_rules! snapshot_tests {
|
macro_rules! snapshot_tests {
|
||||||
($($test_name: ident: $style: expr,)*) => {
|
($($test_name: ident: $style: expr,)*) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user