summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock3
-rw-r--r--Cargo.toml8
-rw-r--r--gen/gen_commands_file.rs2
-rw-r--r--src/bin/jv.rs35
-rw-r--r--src/bin/jvv.rs6
-rw-r--r--utils/Cargo.toml1
-rw-r--r--utils/src/globber.rs17
-rw-r--r--utils/src/logger.rs7
8 files changed, 38 insertions, 41 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ee357f4..bd4b07c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -432,6 +432,7 @@ dependencies = [
"dirs",
"env_logger",
"just_enough_vcs",
+ "just_fmt",
"log",
"strip-ansi-escapes",
"tokio",
@@ -1141,13 +1142,13 @@ dependencies = [
"crossterm",
"erased-serde",
"just_enough_vcs",
+ "just_fmt",
"log",
"regex",
"render_system_macros",
"rust-i18n",
"serde",
"serde_json",
- "string_proc",
"thiserror 2.0.17",
"tokio",
"toml 0.9.8",
diff --git a/Cargo.toml b/Cargo.toml
index 072b8c9..745f431 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,8 +36,7 @@ panic = "abort"
strip = true
[build-dependencies]
-# Just Enough VCS String Formatter
-string_proc = { path = "../VersionControl/utils/string_proc/" }
+just_fmt = "0.1.2"
tokio = { version = "1", features = ["rt", "rt-multi-thread"] }
chrono = "0.4"
@@ -46,7 +45,7 @@ regex = "1.12"
[dependencies]
# Just Enough VCS
-just_enough_vcs = { path = "../VersionControl", features = ["all", "deprecated"] }
+just_enough_vcs = { path = "../VersionControl", features = ["all"] }
# RenderSystem Macros
render_system_macros = { path = "macros/render_system_macros" }
@@ -89,3 +88,6 @@ rust-i18n = "3"
# File & Directory
walkdir = "2.5.0"
+
+# String format
+just_fmt = "0.1.2"
diff --git a/gen/gen_commands_file.rs b/gen/gen_commands_file.rs
index a6b7212..4131154 100644
--- a/gen/gen_commands_file.rs
+++ b/gen/gen_commands_file.rs
@@ -1,6 +1,6 @@
use std::path::PathBuf;
-use string_proc::pascal_case;
+use just_fmt::pascal_case;
use crate::r#gen::constants::{
COMMAND_LIST, COMMAND_LIST_TEMPLATE, COMMANDS_PATH, REGISTRY_TOML, TEMPLATE_END, TEMPLATE_START,
diff --git a/src/bin/jv.rs b/src/bin/jv.rs
index c785358..d1f66a6 100644
--- a/src/bin/jv.rs
+++ b/src/bin/jv.rs
@@ -69,17 +69,14 @@ use just_enough_vcs::{
},
system::action_system::{action::ActionContext, action_pool::ActionPool},
utils::{
- cfg_file::config::ConfigFile,
- data_struct::data_sort::quick_sort_with_cmp,
- sha1_hash,
- string_proc::{
- self,
- format_path::{format_path, format_path_str},
- snake_case,
- },
+ cfg_file::config::ConfigFile, data_struct::data_sort::quick_sort_with_cmp, sha1_hash,
tcp_connection::instance::ConnectionInstance,
},
};
+use just_fmt::{
+ fmt_path::{fmt_path, fmt_path_str},
+ snake_case,
+};
use std::{
collections::{BTreeMap, HashMap, HashSet},
env::{current_dir, set_current_dir},
@@ -1655,7 +1652,7 @@ async fn jv_here(args: HereArgs) {
mapping: if is_dir {
"".to_string()
} else {
- format_path_str(&current_path.display().to_string()).unwrap_or_default()
+ fmt_path_str(&current_path.display().to_string()).unwrap_or_default()
},
name: file_name.clone(),
current_version,
@@ -1685,8 +1682,7 @@ async fn jv_here(args: HereArgs) {
let holder = latest_file_data.file_holder(&metadata.id).cloned();
json_result.items.push(HereJsonResultItem {
- mapping: format_path_str(&current_path.display().to_string())
- .unwrap_or_default(),
+ mapping: fmt_path_str(&current_path.display().to_string()).unwrap_or_default(),
name: name.clone(),
current_version: metadata.version,
size: 0,
@@ -2537,7 +2533,7 @@ async fn jv_info(args: InfoArgs) {
let vfid = mapping.mapping_vfid();
let query_file_path_string =
- format_path_str(query_file_path.display().to_string()).unwrap_or_default();
+ fmt_path_str(query_file_path.display().to_string()).unwrap_or_default();
// JSON output handling
if args.json_output {
@@ -4563,7 +4559,7 @@ async fn jv_move(args: MoveMappingArgs) {
.collect::<Vec<_>>();
let base_path = Globber::from(&to_pattern).base().clone();
- let base_path = format_path(base_path.strip_prefix(&local_dir).unwrap().join("./")).unwrap();
+ let base_path = fmt_path(base_path.strip_prefix(&local_dir).unwrap().join("./")).unwrap();
let to_path = base_path.join(to_pattern);
let mut edit_mapping_args: EditMappingActionArguments = EditMappingActionArguments {
@@ -4581,10 +4577,10 @@ async fn jv_move(args: MoveMappingArgs) {
// Generate move operation parameters
// Single file move
if from_mappings.len() == 1 {
- let from = format_path_str(from_mappings[0].clone()).unwrap();
+ let from = fmt_path_str(from_mappings[0].clone()).unwrap();
let to = if is_to_pattern_a_dir {
// Input is a directory, append the filename
- format_path(
+ fmt_path(
to_path
.join(from.strip_prefix(&base_path.display().to_string()).unwrap())
.to_path_buf(),
@@ -4592,7 +4588,7 @@ async fn jv_move(args: MoveMappingArgs) {
.unwrap()
} else {
// Input is a filename, use it directly
- format_path(to_path.to_path_buf()).unwrap()
+ fmt_path(to_path.to_path_buf()).unwrap()
};
let from: PathBuf = from.into();
@@ -4605,13 +4601,10 @@ async fn jv_move(args: MoveMappingArgs) {
} else
// Multiple file move
if from_mappings.len() > 1 && is_to_pattern_a_dir {
- let to_path = format_path(to_path).unwrap();
+ let to_path = fmt_path(to_path).unwrap();
for p in &from_mappings {
let name = p.strip_prefix(&base_path.display().to_string()).unwrap();
- let to = format_path(to_path.join(name))
- .unwrap()
- .display()
- .to_string();
+ let to = fmt_path(to_path.join(name)).unwrap().display().to_string();
let from: PathBuf = p.into();
// If the from path contains to_path, ignore it to avoid duplicate moves
diff --git a/src/bin/jvv.rs b/src/bin/jvv.rs
index 0cac5c3..b602e9b 100644
--- a/src/bin/jvv.rs
+++ b/src/bin/jvv.rs
@@ -15,12 +15,10 @@ use just_enough_vcs::{
},
env::current_vault_path,
},
- utils::{
- cfg_file::config::ConfigFile,
- string_proc::{self, pascal_case},
- },
+ utils::cfg_file::config::ConfigFile,
};
use just_enough_vcs_cli::data::compile_info::CompileInfo;
+use just_fmt::pascal_case;
use log::{error, info};
use rust_i18n::{set_locale, t};
use tokio::fs::{self};
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()