From 28ea3c189dd1410125e86cf6b4f2d5e60a1104fd Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 1 Dec 2025 11:42:53 +0800 Subject: Add completion helpers for workspace info - Rename HistoryIpAddress to GetHistoryIpAddress for consistency - Add commands to get workspace directory, current account, upstream address, and current sheet --- src/bin/jv.rs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/bin/jv.rs b/src/bin/jv.rs index be0ec2d..8ad929d 100644 --- a/src/bin/jv.rs +++ b/src/bin/jv.rs @@ -199,7 +199,19 @@ enum JustEnoughVcsWorkspaceCommand { // Completion Helpers #[command(name = "_ip_history")] - HistoryIpAddress, + GetHistoryIpAddress, + + #[command(name = "_workspace_dir")] + GetWorkspaceDir, + + #[command(name = "_account")] + GetCurrentAccount, + + #[command(name = "_upstream")] + GetCurrentUpstream, + + #[command(name = "_sheet")] + GetCurrentSheet, } #[derive(Parser, Debug)] @@ -1088,6 +1100,29 @@ async fn main() { .iter() .for_each(|ip| println!("{}", ip)); } + JustEnoughVcsWorkspaceCommand::GetWorkspaceDir => { + if let Some(local_dir) = current_local_path() { + println!("{}", local_dir.display()) + }; + } + JustEnoughVcsWorkspaceCommand::GetCurrentAccount => { + if let Ok(local_config) = LocalConfig::read().await { + println!("{}", local_config.current_account()) + }; + } + JustEnoughVcsWorkspaceCommand::GetCurrentUpstream => { + if let Ok(local_config) = LocalConfig::read().await { + println!("{}", local_config.upstream_addr()) + }; + } + JustEnoughVcsWorkspaceCommand::GetCurrentSheet => { + if let Ok(local_config) = LocalConfig::read().await { + println!( + "{}", + local_config.sheet_in_use().clone().unwrap_or_default() + ) + }; + } } } -- cgit