mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-23 00:24:17 +02:00
Use tree-style imports (#204)
This commit is contained in:
parent
b0449dc6bf
commit
e84fce6f90
8 changed files with 57 additions and 41 deletions
20
src/cache.rs
20
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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
18
src/main.rs
18
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 {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
16
tests/lib.rs
16
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue