From 860f3e90068a63e9f08a161a453802c0d2094f47 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 7 Oct 2018 11:21:41 +0200 Subject: [PATCH] Move InputFile to separate module --- src/app.rs | 8 +------- src/assets.rs | 2 +- src/controller.rs | 3 ++- src/inputfile.rs | 6 ++++++ src/main.rs | 4 +++- src/printer.rs | 3 ++- 6 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 src/inputfile.rs diff --git a/src/app.rs b/src/app.rs index 4f539ede..91a87975 100644 --- a/src/app.rs +++ b/src/app.rs @@ -15,6 +15,7 @@ use ansi_term; use assets::BAT_THEME_DEFAULT; use errors::*; +use inputfile::InputFile; use line_range::LineRange; use style::{OutputComponent, OutputComponents, OutputWrap}; @@ -25,13 +26,6 @@ pub enum PagingMode { Never, } -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum InputFile<'a> { - StdIn, - Ordinary(&'a str), - ThemePreviewFile, -} - #[derive(Clone)] pub struct Config<'a> { /// List of files to print diff --git a/src/assets.rs b/src/assets.rs index 3e3211b3..1ad1f876 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -11,7 +11,7 @@ use syntect::parsing::{SyntaxDefinition, SyntaxSet}; #[cfg(unix)] use std::os::unix::fs::FileTypeExt; -use app::InputFile; +use inputfile::InputFile; lazy_static! { static ref PROJECT_DIRS: ProjectDirs = diff --git a/src/controller.rs b/src/controller.rs index 536c88f3..192c161f 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -1,9 +1,10 @@ use std::fs::File; use std::io::{self, BufRead, BufReader, Write}; -use app::{Config, InputFile}; +use app::Config; use assets::HighlightingAssets; use errors::*; +use inputfile::InputFile; use line_range::LineRange; use output::OutputType; use printer::{InteractivePrinter, Printer, SimplePrinter}; diff --git a/src/inputfile.rs b/src/inputfile.rs new file mode 100644 index 00000000..cc07c7a3 --- /dev/null +++ b/src/inputfile.rs @@ -0,0 +1,6 @@ +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum InputFile<'a> { + StdIn, + Ordinary(&'a str), + ThemePreviewFile, +} diff --git a/src/main.rs b/src/main.rs index adafdd79..5b5941be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,7 @@ mod clap_app; mod controller; mod decorations; mod diff; +mod inputfile; mod line_range; mod output; mod preprocessor; @@ -40,9 +41,10 @@ use std::process; use ansi_term::Colour::Green; use ansi_term::Style; -use app::{App, Config, InputFile}; +use app::{App, Config}; use assets::{clear_assets, config_dir, HighlightingAssets}; use controller::Controller; +use inputfile::InputFile; use style::{OutputComponent, OutputComponents}; mod errors { diff --git a/src/printer.rs b/src/printer.rs index 50a54c02..8959c81f 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -10,12 +10,13 @@ use console::AnsiCodeIterator; use syntect::easy::HighlightLines; use syntect::highlighting::Theme; -use app::{Config, InputFile}; +use app::Config; use assets::HighlightingAssets; use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration}; use diff::get_git_diff; use diff::LineChanges; use errors::*; +use inputfile::InputFile; use preprocessor::expand; use style::OutputWrap; use terminal::{as_terminal_escaped, to_ansi_color};