diff --git a/src/cache.rs b/src/cache.rs index fb55349..0e2ea2c 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,9 +1,11 @@ -use std::env; -use std::ffi::OsStr; -use std::fs; -use std::io::Read; -use std::iter; -use std::path::{Path, PathBuf}; +use std::{ + env, + ffi::OsStr, + fs, + io::Read, + iter, + path::{Path, PathBuf}, +}; use app_dirs::{get_app_root, AppDataType}; use flate2::read::GzDecoder; @@ -13,8 +15,10 @@ use std::time::{Duration, SystemTime}; use tar::Archive; use walkdir::{DirEntry, WalkDir}; -use crate::error::TealdeerError::{self, CacheError, UpdateError}; -use crate::types::{OsType, PathSource}; +use crate::{ + error::TealdeerError::{self, CacheError, UpdateError}, + types::{OsType, PathSource}, +}; static CACHE_DIR_ENV_VAR: &str = "TEALDEER_CACHE_DIR"; diff --git a/src/config.rs b/src/config.rs index a2f49ee..a4730fc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,16 +1,19 @@ -use std::env; -use std::fs; -use std::io::{Error as IoError, Read, Write}; -use std::path::PathBuf; -use std::time::Duration; +use std::{ + env, fs, + io::{Error as IoError, Read, Write}, + path::PathBuf, + time::Duration, +}; use ansi_term::{Color, Style}; use app_dirs::{get_app_root, AppDataType}; use log::debug; use serde_derive::{Deserialize, Serialize}; -use crate::error::TealdeerError::{self, ConfigError}; -use crate::types::PathSource; +use crate::{ + error::TealdeerError::{self, ConfigError}, + types::PathSource, +}; pub const CONFIG_FILE_NAME: &str = "config.toml"; pub const MAX_CACHE_AGE: Duration = Duration::from_secs(2_592_000); // 30 days diff --git a/src/error.rs b/src/error.rs index e85971d..548c39f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,7 @@ -use reqwest::Error as ReqwestError; use std::fmt; +use reqwest::Error as ReqwestError; + #[derive(Debug)] #[allow(clippy::enum_variant_names)] pub enum TealdeerError { diff --git a/src/formatter.rs b/src/formatter.rs index d1cfde4..ede13c3 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -1,7 +1,6 @@ //! Functions related to formatting and printing lines from a `Tokenizer`. -use crate::extensions::FindFrom; -use crate::types::LineType; +use crate::{extensions::FindFrom, types::LineType}; use log::debug; diff --git a/src/line_iterator.rs b/src/line_iterator.rs index c1fbb0f..4d0eab6 100644 --- a/src/line_iterator.rs +++ b/src/line_iterator.rs @@ -2,9 +2,10 @@ use std::io::BufRead; -use crate::types::LineType; use log::warn; +use crate::types::LineType; + #[derive(Debug, PartialEq, Eq)] pub enum TldrFormat { /// Not yet clear diff --git a/src/main.rs b/src/main.rs index 69011b9..59986a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,9 +15,7 @@ #![allow(clippy::similar_names)] #![allow(clippy::too_many_lines)] -use std::env; -use std::path::PathBuf; -use std::process; +use std::{env, path::PathBuf, process}; use ansi_term::{Color, Style}; use app_dirs::AppInfo; @@ -36,12 +34,14 @@ mod line_iterator; mod output; mod types; -use crate::cache::{Cache, PageLookupResult}; -use crate::config::{get_config_dir, get_config_path, make_default_config, Config, MAX_CACHE_AGE}; -use crate::error::TealdeerError::ConfigError; -use crate::extensions::Dedup; -use crate::output::print_page; -use crate::types::{ColorOptions, OsType}; +use crate::{ + cache::{Cache, PageLookupResult}, + config::{get_config_dir, get_config_path, make_default_config, Config, MAX_CACHE_AGE}, + error::TealdeerError::ConfigError, + extensions::Dedup, + output::print_page, + types::{ColorOptions, OsType}, +}; const NAME: &str = "tealdeer"; const APP_INFO: AppInfo = AppInfo { diff --git a/src/output.rs b/src/output.rs index 25b9bc3..70cd138 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,13 +1,17 @@ //! Functions for printing pages to the terminal -use std::fs::File; -use std::io::{self, BufRead, BufReader, Write}; +use std::{ + fs::File, + io::{self, BufRead, BufReader, Write}, +}; -use crate::cache::PageLookupResult; -use crate::config::{Config, StyleConfig}; -use crate::error::TealdeerError::WriteError; -use crate::formatter::{highlight_lines, PageSnippet}; -use crate::line_iterator::LineIterator; +use crate::{ + cache::PageLookupResult, + config::{Config, StyleConfig}, + error::TealdeerError::WriteError, + formatter::{highlight_lines, PageSnippet}, + line_iterator::LineIterator, +}; /// Print page by path pub fn print_page( diff --git a/tests/lib.rs b/tests/lib.rs index a6414e6..2926c75 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,13 +1,17 @@ //! Integration tests. -use std::fs::{create_dir_all, File}; -use std::io::Write; -use std::process::Command; -use std::time::{Duration, SystemTime}; +use std::{ + fs::{create_dir_all, File}, + io::Write, + process::Command, + time::{Duration, SystemTime}, +}; use assert_cmd::prelude::*; -use predicates::boolean::PredicateBooleanExt; -use predicates::prelude::predicate::str::{contains, diff, is_empty}; +use predicates::{ + boolean::PredicateBooleanExt, + prelude::predicate::str::{contains, diff, is_empty}, +}; use tempfile::{Builder, TempDir}; // TODO: Should be 'cache::CACHE_DIR_ENV_VAR'. This requires to have a library crate for the logic.