diff options
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/Cargo.toml | 1 | ||||
| -rw-r--r-- | utils/src/globber.rs | 17 | ||||
| -rw-r--r-- | utils/src/logger.rs | 7 |
3 files changed, 14 insertions, 11 deletions
diff --git a/utils/Cargo.toml b/utils/Cargo.toml index b4df110..c055c07 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -10,6 +10,7 @@ just_enough_vcs = { path = "../../VersionControl", features = ["all"] } # Display colored = "3.0" strip-ansi-escapes = "0.2.1" +just_fmt = "0.1.2" # Async tokio = { version = "1", features = ["full"] } diff --git a/utils/src/globber.rs b/utils/src/globber.rs index e20caf9..7021898 100644 --- a/utils/src/globber.rs +++ b/utils/src/globber.rs @@ -1,6 +1,6 @@ use std::{io::Error, path::PathBuf, str::FromStr}; -use just_enough_vcs::utils::string_proc::format_path::format_path_str; +use just_fmt::fmt_path::fmt_path_str; use crate::globber::constants::{SPLIT_STR, get_base_dir_current}; @@ -48,10 +48,13 @@ impl Globber { if !path.ends_with(SPLIT_STR) { path.push_str(SPLIT_STR); } - ( - format_path_str(path)?, - pattern_part[SPLIT_STR.len()..].to_string(), - ) + let Ok(result) = fmt_path_str(&path) else { + return Err(Error::new( + std::io::ErrorKind::InvalidInput, + format!("Invalid path: \"{}\"", &path), + )); + }; + (result, pattern_part[SPLIT_STR.len()..].to_string()) } else { (String::default(), full_path) }; @@ -103,14 +106,14 @@ impl Globber { match item { GlobItem::File(file_name) => { let relative_path = { - format_path_str(format!("{}{}{}", current, SPLIT_STR, file_name)) + fmt_path_str(format!("{}{}{}", current, SPLIT_STR, file_name)) .unwrap_or_default() }; file_names.push(relative_path) } GlobItem::Directory(dir_name) => { let new_current = { - format_path_str(format!("{}{}{}", current, SPLIT_STR, dir_name)) + fmt_path_str(format!("{}{}{}", current, SPLIT_STR, dir_name)) .unwrap_or_default() }; collect_files(base, new_current, file_names, get_names); diff --git a/utils/src/logger.rs b/utils/src/logger.rs index 6c9b95b..1bc96c1 100644 --- a/utils/src/logger.rs +++ b/utils/src/logger.rs @@ -2,9 +2,8 @@ use std::path::Path; use colored::Colorize; use env_logger::{Builder, Target}; -use just_enough_vcs::{ - lib::data::vault::vault_config::LoggerLevel, utils::string_proc::format_path::format_path, -}; +use just_enough_vcs::lib::data::vault::vault_config::LoggerLevel; +use just_fmt::fmt_path::fmt_path; use log::{Level, LevelFilter}; pub fn build_env_logger(log_path: impl AsRef<Path>, logger_level: LoggerLevel) { @@ -35,7 +34,7 @@ pub fn build_env_logger(log_path: impl AsRef<Path>, logger_level: LoggerLevel) { let log_path = { let path = log_path.as_ref(); - let Ok(path) = format_path(path) else { + let Ok(path) = fmt_path(path) else { eprintln!( "Build logger failed: {} is not a vaild path.", path.display() |
