This commit is contained in:
veeso
2023-05-09 15:40:21 +02:00
parent 9009002b6e
commit c5eeae74b7
83 changed files with 398 additions and 358 deletions

View File

@@ -3,11 +3,12 @@
//! `builder` is the module which provides a builder for FileExplorer
// Locals
use super::formatter::Formatter;
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
// Ext
use std::collections::VecDeque;
use super::formatter::Formatter;
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
/// Struct used to create a `FileExplorer`
pub struct FileExplorerBuilder {
explorer: Option<FileExplorer>,
@@ -76,10 +77,10 @@ impl FileExplorerBuilder {
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
use super::*;
#[test]
fn test_fs_explorer_builder_new_default() {
let explorer: FileExplorer = FileExplorerBuilder::new().build();

View File

@@ -3,18 +3,20 @@
//! `formatter` is the module which provides formatting utilities for `FileExplorer`
// Locals
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time};
use crate::utils::path::diff_paths;
use crate::utils::string::secure_substring;
use std::path::PathBuf;
use std::time::UNIX_EPOCH;
// Ext
use bytesize::ByteSize;
use lazy_regex::{Lazy, Regex};
use remotefs::File;
use std::path::PathBuf;
use std::time::UNIX_EPOCH;
use unicode_width::UnicodeWidthStr;
#[cfg(target_family = "unix")]
use users::{get_group_by_gid, get_user_by_uid};
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time};
use crate::utils::path::diff_paths;
use crate::utils::string::secure_substring;
// Types
// FmtCallback: Formatter, fsentry: &File, cur_str, prefix, length, extra
type FmtCallback = fn(&Formatter, &File, &str, &str, Option<&usize>, Option<&String>) -> String;
@@ -521,12 +523,13 @@ impl Formatter {
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
use std::time::SystemTime;
use pretty_assertions::assert_eq;
use remotefs::fs::{File, FileType, Metadata, UnixPex};
use std::path::PathBuf;
use std::time::SystemTime;
use super::*;
#[test]
fn test_fs_explorer_formatter_callchain() {

View File

@@ -6,15 +6,16 @@
pub(crate) mod builder;
mod formatter;
// Locals
use formatter::Formatter;
// Ext
use remotefs::fs::File;
use std::cmp::Reverse;
use std::collections::VecDeque;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::string::ToString;
use formatter::Formatter;
// Ext
use remotefs::fs::File;
bitflags! {
/// ExplorerOpts are bit options which provides different behaviours to `FileExplorer`
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
@@ -289,13 +290,14 @@ impl FromStr for GroupDirs {
#[cfg(test)]
mod tests {
use super::*;
use crate::utils::fmt::fmt_time;
use std::thread::sleep;
use std::time::{Duration, SystemTime};
use pretty_assertions::assert_eq;
use remotefs::fs::{File, FileType, Metadata, UnixPex};
use std::thread::sleep;
use std::time::{Duration, SystemTime};
use super::*;
use crate::utils::fmt::fmt_time;
#[test]
fn test_fs_explorer_new() {