Skip to content

Commit 9e96355

Browse files
committed
.
1 parent 32bf317 commit 9e96355

17 files changed

+162
-66
lines changed

Makefile

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ PKG_FLAGS = $(if $(crate),-p $(crate))
2828
wtest2 \
2929
wtest3 \
3030
wtest4 \
31-
wtest5
31+
wtest5 \
32+
clean-cache-files
3233

3334
#
3435
# === Help ===
@@ -62,6 +63,9 @@ help:
6263
@echo " wtest4 [crate=..] - Watch Level 4: All checks + Heavy testing (deps + audit)."
6364
@echo " wtest5 [crate=..] - Watch Level 5: Full heavy testing with mutations."
6465
@echo ""
66+
@echo "Cache Management:"
67+
@echo " clean-cache-files - Add hyphen prefix to cache files for git exclusion."
68+
@echo ""
6569

6670

6771
#
@@ -164,7 +168,8 @@ ctest4:
164168
RUSTDOCFLAGS="-D warnings" cargo test --doc $(PKG_FLAGS) && \
165169
cargo clippy --all-targets --all-features $(PKG_FLAGS) -- -D warnings && \
166170
cargo +nightly udeps --all-targets $(PKG_FLAGS) && \
167-
cargo +nightly audit $(PKG_FLAGS)
171+
cargo +nightly audit $(PKG_FLAGS) && \
172+
$(MAKE) --no-print-directory clean-cache-files
168173

169174
# Test Level 5: Full heavy testing with mutation tests.
170175
#
@@ -178,7 +183,8 @@ ctest5:
178183
cargo clippy --all-targets --all-features $(PKG_FLAGS) -- -D warnings && \
179184
willbe .test dry:0 && \
180185
cargo +nightly udeps --all-targets $(PKG_FLAGS) && \
181-
cargo +nightly audit $(PKG_FLAGS)
186+
cargo +nightly audit $(PKG_FLAGS) && \
187+
$(MAKE) --no-print-directory clean-cache-files
182188

183189
#
184190
# === Watch Commands ===
@@ -214,12 +220,30 @@ wtest3:
214220
# make wtest4 [crate=name]
215221
wtest4:
216222
@echo "Watching Level 4: All checks + Heavy testing..."
217-
@cargo watch -c --shell "RUSTFLAGS=\"-D warnings\" cargo nextest run $(PKG_FLAGS) && RUSTDOCFLAGS=\"-D warnings\" cargo test --doc $(PKG_FLAGS) && cargo clippy --all-targets --all-features $(PKG_FLAGS) -- -D warnings && cargo +nightly udeps --all-targets $(PKG_FLAGS) && cargo +nightly audit $(PKG_FLAGS)"
223+
@cargo watch -c --shell "RUSTFLAGS=\"-D warnings\" cargo nextest run $(PKG_FLAGS) && RUSTDOCFLAGS=\"-D warnings\" cargo test --doc $(PKG_FLAGS) && cargo clippy --all-targets --all-features $(PKG_FLAGS) -- -D warnings && cargo +nightly udeps --all-targets $(PKG_FLAGS) && cargo +nightly audit $(PKG_FLAGS) && make --no-print-directory clean-cache-files"
218224

219225
# Watch Level 5: Full heavy testing with mutations.
220226
#
221227
# Usage :
222228
# make wtest5 [crate=name]
223229
wtest5:
224230
@echo "Watching Level 5: Full heavy testing..."
225-
@cargo watch -c --shell "RUSTFLAGS=\"-D warnings\" cargo nextest run $(PKG_FLAGS) && RUSTDOCFLAGS=\"-D warnings\" cargo test --doc $(PKG_FLAGS) && cargo clippy --all-targets --all-features $(PKG_FLAGS) -- -D warnings && willbe .test dry:0 && cargo +nightly udeps --all-targets $(PKG_FLAGS) && cargo +nightly audit $(PKG_FLAGS)"
231+
@cargo watch -c --shell "RUSTFLAGS=\"-D warnings\" cargo nextest run $(PKG_FLAGS) && RUSTDOCFLAGS=\"-D warnings\" cargo test --doc $(PKG_FLAGS) && cargo clippy --all-targets --all-features $(PKG_FLAGS) -- -D warnings && willbe .test dry:0 && cargo +nightly udeps --all-targets $(PKG_FLAGS) && cargo +nightly audit $(PKG_FLAGS) && make --no-print-directory clean-cache-files"
232+
233+
#
234+
# === Cache Cleanup ===
235+
#
236+
237+
# Clean cache files created by cargo audit and other tools by adding hyphen prefix.
238+
# This ensures they are ignored by git while preserving the data for future runs.
239+
#
240+
# Usage :
241+
# make clean-cache-files
242+
clean-cache-files:
243+
@echo "Cleaning cache files (adding hyphen prefix for git exclusion)..."
244+
@if [ -d "advisory-db" ]; then mv advisory-db -advisory-db 2>/dev/null || true; fi
245+
@if [ -f "advisory-db..lock" ]; then mv advisory-db..lock -advisory-db..lock 2>/dev/null || true; fi
246+
@if [ -d ".global-cache" ]; then mv .global-cache -.global-cache 2>/dev/null || true; fi
247+
@if [ -d ".package-cache" ]; then mv .package-cache -.package-cache 2>/dev/null || true; fi
248+
@if [ -d "registry" ]; then mv registry -registry 2>/dev/null || true; fi
249+
@echo "Cache files cleaned successfully."

module/move/unilang/Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ keywords = [ "wtools", "CLI", "CUI", "user-interface" ]
2121
workspace = true
2222

2323
[package.metadata.docs.rs]
24-
features = [ "full", "error_tools/enabled", "mod_interface/enabled", "iter_tools/enabled", "former/enabled" ]
24+
features = [ "full", "error_tools/enabled", "mod_interface/enabled", "former/enabled" ]
2525
all-features = false
2626

2727
[features]
@@ -48,7 +48,7 @@ repl = []
4848
enhanced_repl = [ "repl", "dep:rustyline", "dep:atty" ]
4949

5050
# This configuration suggests an action to be done when the command is unknown. In this case, when an unknown command is encountered, the system might suggest alternatives
51-
on_unknown_suggest = [ "dep:textdistance" ]
51+
on_unknown_suggest = [ ]
5252

5353
[dependencies]
5454
serde = { version = "1.0", features = ["derive"] }
@@ -62,15 +62,12 @@ phf = { version = "0.11", features = ["macros"] }
6262
## internal
6363
error_tools = { workspace = true, features = [ "enabled", "error_typed", "error_untyped" ] }
6464
mod_interface = { workspace = true, features = [ "enabled" ] }
65-
iter_tools = { workspace = true, features = [ "enabled" ] }
6665
former = { workspace = true, features = [ "enabled", "derive_former" ] }
6766
unilang_parser = { workspace = true } # SIMD features controlled by main unilang features
68-
strs_tools = { workspace = true, features = [ "enabled", "simd" ] } # SIMD-optimized string processing
6967

7068
## external
7169
log = "0.4"
7270
#closure = "0.3"
73-
textdistance = { version = "1.0", optional = true } # fuzzy commands search
7471
rustyline = { version = "14.0", optional = true } # Enhanced REPL with history and arrow keys
7572
atty = { version = "0.2", optional = true } # Terminal detection for enhanced REPL
7673
indexmap = "2.2.6"
@@ -163,7 +160,6 @@ path = "benchmarks/run_all_benchmarks.rs"
163160

164161

165162
[build-dependencies]
166-
phf_codegen = "0.11"
167163
serde = "1.0"
168164
serde_yaml = "0.9"
169165

module/move/unilang/examples/repl_comparison.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
//!
33
//! This example demonstrates the differences between basic and enhanced REPL modes,
44
//! allowing you to see both implementations side-by-side.
5+
6+
#![ allow( clippy::needless_continue ) ]
7+
#![ allow( clippy::uninlined_format_args ) ]
8+
#![ allow( clippy::cast_lossless ) ]
9+
#![ allow( clippy::std_instead_of_core ) ]
10+
#![ allow( clippy::manual_string_new ) ]
11+
#![ allow( clippy::collapsible_else_if ) ]
512
//!
613
//! ## Features Comparison
714
//!

module/move/unilang/readme.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -882,34 +882,44 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
882882
**Step 3: Handling Interactive Arguments**
883883
Enhanced REPL provides better support for interactive arguments:
884884

885-
```rust
885+
```rust,no_run
886886
use unilang::prelude::*;
887887
888-
// In your REPL loop
889-
let result = pipeline.process_command_simple(&input);
890-
891-
if result.requires_interactive_input() {
892-
if let Some(arg_name) = result.interactive_argument() {
893-
#[cfg(feature = "enhanced_repl")]
894-
{
895-
// Enhanced REPL: Secure password prompt with masking
896-
use rustyline::DefaultEditor;
897-
let mut rl = DefaultEditor::new()?;
898-
let password = rl.readline(&format!("Enter {}: ", arg_name))?;
899-
// Re-run command with interactive argument...
900-
}
901-
902-
#[cfg(all(feature = "repl", not(feature = "enhanced_repl")))]
903-
{
904-
// Basic REPL: Standard input (visible)
905-
use std::io::{self, Write};
906-
print!("Enter {}: ", arg_name);
907-
io::stdout().flush()?;
908-
let mut value = String::new();
909-
io::stdin().read_line(&mut value)?;
910-
// Re-run command with interactive argument...
911-
}
888+
fn handle_interactive_input() -> Result< (), Box< dyn std::error::Error > >
889+
{
890+
let registry = CommandRegistry::new();
891+
let mut pipeline = Pipeline::new( registry );
892+
let input = String::from( "example_command" );
893+
894+
// In your REPL loop
895+
let result = pipeline.process_command_simple( &input );
896+
897+
if result.requires_interactive_input()
898+
{
899+
if let Some( arg_name ) = result.interactive_argument()
900+
{
901+
#[ cfg( feature = "enhanced_repl" ) ]
902+
{
903+
// Enhanced REPL: Secure password prompt with masking
904+
use rustyline::DefaultEditor;
905+
let mut rl = DefaultEditor::new()?;
906+
let password = rl.readline( &format!( "Enter {}: ", arg_name ) )?;
907+
// Re-run command with interactive argument...
908+
}
909+
910+
#[ cfg( all( feature = "repl", not( feature = "enhanced_repl" ) ) ) ]
911+
{
912+
// Basic REPL: Standard input (visible)
913+
use std::io::{ self, Write };
914+
print!( "Enter {}: ", arg_name );
915+
io::stdout().flush()?;
916+
let mut value = String::new();
917+
io::stdin().read_line( &mut value )?;
918+
// Re-run command with interactive argument...
919+
}
912920
}
921+
}
922+
Ok( () )
913923
}
914924
```
915925

module/move/unilang/src/pipeline.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl CommandResult
152152
#[ must_use ]
153153
pub fn error_message( &self ) -> Option< &str >
154154
{
155-
self.error.as_ref().map( |e| e.as_str() )
155+
self.error.as_deref()
156156
}
157157

158158
/// Returns outputs if command succeeded, empty slice otherwise.
@@ -171,7 +171,7 @@ impl CommandResult
171171
}
172172
}
173173

174-
/// Parses the error message into a structured UnilangError type.
174+
/// Parses the error message into a structured `UnilangError` type.
175175
///
176176
/// This enables type-safe error handling instead of fragile string matching.
177177
/// Returns None if the command succeeded.
@@ -377,10 +377,7 @@ fn extract_interactive_argument( error_msg : &str ) -> Option< &str >
377377
{
378378
return Some( &arg_part[ ..arg_end ] );
379379
}
380-
else
381-
{
382-
return Some( arg_part );
383-
}
380+
return Some( arg_part );
384381
}
385382
}
386383

@@ -408,10 +405,7 @@ fn extract_command_from_error( error_msg : &str ) -> Option< &str >
408405
{
409406
return Some( &after[ ..end ] );
410407
}
411-
else
412-
{
413-
return Some( after );
414-
}
408+
return Some( after );
415409
}
416410

417411
// Look for "command '<name>'" pattern
@@ -453,16 +447,16 @@ fn extract_available_commands( error_msg : &str ) -> Vec< String >
453447

454448
// Extract command names - they typically start with '.'
455449
// Handle various indentation patterns
456-
if line.starts_with( '.' )
450+
if let Some( stripped ) = line.strip_prefix( '.' )
457451
{
458452
// Direct command line
459-
if let Some( cmd_end ) = line.find( ' ' )
453+
if let Some( cmd_end ) = stripped.find( ' ' )
460454
{
461-
commands.push( line[ 1..cmd_end ].to_string() ); // Skip the '.'
455+
commands.push( stripped[ ..cmd_end ].to_string() );
462456
}
463457
else
464458
{
465-
commands.push( line[ 1.. ].to_string() );
459+
commands.push( stripped.to_string() );
466460
}
467461
}
468462
else if line.contains( '.' )

module/move/unilang/tests/api_consistency_command_result_test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
//! Tests for API consistency improvements to CommandResult and error handling.
1+
//! Tests for API consistency improvements to `CommandResult` and error handling.
22
//!
33
//! This module tests the implementation of task 019, which improves API consistency
4-
//! by adding helper methods to CommandResult and structured error types.
4+
//! by adding helper methods to `CommandResult` and structured error types.
5+
6+
#![ allow( clippy::doc_markdown ) ]
57

68
use unilang::{ CommandResult, UnilangError, OutputData };
79

module/move/unilang/tests/command_registry_debug_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//! and retrieval of commands using fully qualified names, including debug prints
77
//! of string keys and their byte representations.
88
//!
9+
10+
#![ allow( clippy::uninlined_format_args ) ]
911
//! | ID | Test Case | Expected Behavior | Debug Output |
1012
//! |---|---|---|---|
1113
//! | T-REG-1 | Register and retrieve command with namespace | Command should be found using its fully qualified name. | Print registered key and lookup key with byte representations. |

module/move/unilang/tests/command_runtime_registration_failure_mre.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! MRE test for issue 017: Command Runtime Registration Failure
22
3+
#![ allow( clippy::doc_markdown ) ]
4+
#![ allow( clippy::unnecessary_wraps ) ]
5+
#![ allow( clippy::uninlined_format_args ) ]
6+
#![ allow( clippy::inefficient_to_string ) ]
7+
38
use unilang::{ CommandDefinition, CommandRegistry, Pipeline, ExecutionContext, VerifiedCommand, OutputData, ErrorData };
49

510
/// MRE test for issue 017: Command Runtime Registration Failure

module/move/unilang/tests/command_validation_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
//! Tests that the framework enforces explicit dot prefixes and rejects
44
//! commands that don't follow the naming requirements.
55
6+
#![ allow( clippy::unnecessary_wraps ) ]
7+
#![ allow( clippy::uninlined_format_args ) ]
8+
#![ allow( clippy::print_literal ) ]
9+
#![ allow( clippy::single_char_pattern ) ]
10+
611
use unilang::{ CommandDefinition, CommandRegistry, ExecutionContext, VerifiedCommand, OutputData, ErrorData };
712

813
fn dummy_handler(_cmd: VerifiedCommand, _ctx: ExecutionContext) -> Result< OutputData, ErrorData >

module/move/unilang/tests/integration_complete_system_test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
//! This test validates that issue 017 has been completely resolved and that
44
//! the governing principle of "Minimum Implicit Magic" is properly enforced.
55
6+
#![ allow( clippy::needless_pass_by_value ) ]
7+
#![ allow( clippy::unnecessary_wraps ) ]
8+
#![ allow( clippy::too_many_lines ) ]
9+
#![ allow( clippy::inefficient_to_string ) ]
10+
#![ allow( clippy::uninlined_format_args ) ]
11+
#![ allow( clippy::map_unwrap_or ) ]
12+
613
use unilang::{ CommandDefinition, CommandRegistry, Pipeline, ExecutionContext, VerifiedCommand, OutputData, ErrorData };
714

815
fn demo_handler(cmd: VerifiedCommand, _ctx: ExecutionContext) -> Result< OutputData, ErrorData >

0 commit comments

Comments
 (0)