From 49b9037168fb5b6c8deb7ab06abbfd6f54ebc798 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 24 Jan 2026 03:10:41 +0800 Subject: Split prepare phase into prepare and collect - Prepare now handles argument-to-input conversion only - Collect handles resource gathering and data collection - Status command updated to use new two-phase structure - Command system trait modified to support separate phases --- src/cmds/status.rs | 83 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'src/cmds') diff --git a/src/cmds/status.rs b/src/cmds/status.rs index 54e033e..cb10150 100644 --- a/src/cmds/status.rs +++ b/src/cmds/status.rs @@ -1,9 +1,12 @@ -use std::time::SystemTime; +use std::{collections::HashMap, time::SystemTime}; -use just_enough_vcs::vcs::constants::VAULT_HOST_NAME; +use just_enough_vcs::vcs::{ + constants::VAULT_HOST_NAME, data::local::workspace_analyzer::ModifiedRelativePathBuf, +}; use crate::{ arguments::status::JVStatusArgument, + collects::status::JVStatusCollect, inputs::status::JVStatusInput, outputs::status::{JVStatusOutput, JVStatusWrongModifyReason}, renderers::status::JVStatusRenderer, @@ -16,16 +19,23 @@ use crate::{ pub struct JVStatusCommand; -impl JVCommand +impl JVCommand for JVStatusCommand { async fn prepare( - _args: JVStatusArgument, - _ctx: JVCommandContext, + _args: &JVStatusArgument, + _ctx: &JVCommandContext, ) -> Result { + Ok(JVStatusInput) + } + + async fn collect( + _args: &JVStatusArgument, + _ctx: &JVCommandContext, + ) -> Result { // Initialize a reader for the local workspace and a default result structure let mut reader = LocalWorkspaceReader::default(); - let mut input = JVStatusInput::default(); + let mut collect = JVStatusCollect::default(); // Analyze the current status of the local workspace // (detects changes like created, modified, moved, etc.) @@ -58,26 +68,31 @@ impl JVCommand Result { - let latest_file_data = &input.latest_file_data; + async fn exec( + _input: JVStatusInput, + collect: JVStatusCollect, + ) -> Result { + let mut wrong_modified_items: HashMap = + HashMap::new(); + + let latest_file_data = &collect.latest_file_data; // Calculate whether modifications are correc - let modified = &input.analyzed_result.modified; + let modified = &collect.analyzed_result.modified; for item in modified { // Get mapping - let Ok(mapping) = input.local_sheet_data.mapping_data(&item) else { + let Ok(mapping) = collect.local_sheet_data.mapping_data(&item) else { continue; }; @@ -93,7 +108,7 @@ impl JVCommand