diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-25 07:48:47 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-25 07:48:47 +0800 |
| commit | 5f3d4892a12189e88e692eabdd5f8fe68c79b23e (patch) | |
| tree | 315e67e2efc2ca88d8e25aeb98626b1169241b17 /utils/src | |
| parent | 5dd853c5371bf26d7bf3774f3c03088fb15f84a3 (diff) | |
Replace string_proc with just_fmt dependency
Diffstat (limited to 'utils/src')
| -rw-r--r-- | utils/src/globber.rs | 17 | ||||
| -rw-r--r-- | utils/src/logger.rs | 7 |
2 files changed, 13 insertions, 11 deletions
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() |
