From 2e9c78ce5997661a5668cc8bc0fd9d922c2320b8 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 4 May 2026 15:58:37 +0800 Subject: Add `--active` flag to workspace sheet command --- Cargo.lock | 101 +++++++++++---------- Cargo.toml | 1 - resources/helpdoc/commands/workspace/sheet.en.md | 2 + .../helpdoc/commands/workspace/sheet.zh-CN.md | 2 + resources/locales/jvn/cmds/workspace/sheet/en.yml | 12 ++- .../locales/jvn/cmds/workspace/sheet/zh-CN.yml | 4 + resources/locales/jvn/en.yml | 1 - resources/locales/jvn/zh-CN.yml | 1 - src/cmds/arg/workspace_sheet.rs | 3 + src/cmds/cmd/workspace_sheet.rs | 35 +++++-- src/cmds/comp/workspace_sheet.rs | 6 +- src/cmds/in/workspace_sheet.rs | 1 + 12 files changed, 106 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00f855e..75aa616 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,9 +214,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.11.0-rc.5" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ef36a6fcdb072aa548f3da057640ec10859eb4e91ddf526ee648d50c76a949" +checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" dependencies = [ "hybrid-array", ] @@ -432,6 +432,12 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + [[package]] name = "constant_time_eq" version = "0.3.1" @@ -569,23 +575,23 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.2.0-rc.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8235645834fbc6832939736ce2f2d08192652269e11010a6240f61b908a1c6" +checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710" dependencies = [ "hybrid-array", ] [[package]] name = "curve25519-dalek" -version = "5.0.0-pre.1" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f9200d1d13637f15a6acb71e758f64624048d85b31a5fdbfd8eca1e2687d0b7" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures 0.2.17", "curve25519-dalek-derive", - "digest 0.11.0-rc.3", + "digest 0.10.7", "fiat-crypto", "rustc_version", "subtle", @@ -617,7 +623,7 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ - "const-oid", + "const-oid 0.9.6", "pem-rfc7468", "zeroize", ] @@ -651,19 +657,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", + "const-oid 0.9.6", "crypto-common 0.1.6", "subtle", ] [[package]] name = "digest" -version = "0.11.0-rc.3" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac89f8a64533a9b0eaa73a68e424db0fb1fd6271c74cc0125336a05f090568d" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.11.0-rc.5", - "crypto-common 0.2.0-rc.4", + "block-buffer 0.12.0", + "const-oid 0.10.2", + "crypto-common 0.2.1", ] [[package]] @@ -698,22 +705,24 @@ dependencies = [ [[package]] name = "ed25519" -version = "3.0.0-rc.1" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef49c0b20c0ad088893ad2a790a29c06a012b3f05bcfc66661fd22a94b32129" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "signature 3.0.0-rc.4", + "pkcs8", + "signature", ] [[package]] name = "ed25519-dalek" -version = "3.0.0-pre.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad207ed88a133091f83224265eac21109930db09bedcad05d5252f2af2de20a1" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" dependencies = [ "curve25519-dalek", "ed25519", - "sha2 0.11.0-rc.2", + "serde", + "sha2 0.10.9", "subtle", "zeroize", ] @@ -765,9 +774,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.3.0" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "find-msvc-tools" @@ -1012,9 +1021,9 @@ dependencies = [ [[package]] name = "hybrid-array" -version = "0.4.5" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f471e0a81b2f90ffc0cb2f951ae04da57de8baa46fa99112b062a5173a5088d0" +checksum = "08d46837a0ed51fe95bd3b05de33cd64a1ee88fc797477ca48446872504507c5" dependencies = [ "typenum", ] @@ -1258,9 +1267,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libm" @@ -1322,9 +1331,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" dependencies = [ "libc", "log", @@ -1752,7 +1761,7 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" dependencies = [ - "const-oid", + "const-oid 0.9.6", "digest 0.10.7", "num-bigint-dig", "num-integer", @@ -1761,7 +1770,7 @@ dependencies = [ "pkcs8", "rand_core 0.6.4", "sha2 0.10.9", - "signature 2.2.0", + "signature", "spki", "subtle", "zeroize", @@ -2003,13 +2012,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.11.0-rc.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1e3878ab0f98e35b2df35fe53201d088299b41a6bb63e3e34dada2ac4abd924" +checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", - "digest 0.11.0-rc.3", + "cpufeatures 0.3.0", + "digest 0.11.3", ] [[package]] @@ -2022,7 +2031,7 @@ dependencies = [ "just_fmt", "memmap2", "serde", - "sha2 0.10.9", + "sha2 0.11.0", "sheet_system_macros", "thiserror", "tokio", @@ -2083,12 +2092,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "signature" -version = "3.0.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc280a6ff65c79fbd6622f64d7127f32b85563bca8c53cd2e9141d6744a9056d" - [[package]] name = "siphasher" version = "1.0.1" @@ -2109,12 +2112,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -2223,9 +2226,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.50.0" +version = "1.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +checksum = "b67dee974fe86fd92cc45b7a95fdd2f99a36a6d7b0d431a231178d3d670bbcc6" dependencies = [ "bytes", "libc", @@ -2240,9 +2243,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", @@ -2342,9 +2345,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" [[package]] name = "unicode-ident" diff --git a/Cargo.toml b/Cargo.toml index d66723d..93dba06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ panic = "unwind" [profile.release] opt-level = "z" debug = false -split-defoinfo = "off" codegen-units = 1 incremental = false lto = "thin" diff --git a/resources/helpdoc/commands/workspace/sheet.en.md b/resources/helpdoc/commands/workspace/sheet.en.md index 3e4a158..9890f6a 100644 --- a/resources/helpdoc/commands/workspace/sheet.en.md +++ b/resources/helpdoc/commands/workspace/sheet.en.md @@ -2,12 +2,14 @@ ## Usage jvn workspace sheet +__ --active # Active a sheet __ --new # Create a sheet __ --delete # Delete a sheet __ --print-path # Print the sheet path __ --list-all # List all sheets ## Aliases +__ -a __ -n __ -d __ -p diff --git a/resources/helpdoc/commands/workspace/sheet.zh-CN.md b/resources/helpdoc/commands/workspace/sheet.zh-CN.md index 3e8880b..731828b 100644 --- a/resources/helpdoc/commands/workspace/sheet.zh-CN.md +++ b/resources/helpdoc/commands/workspace/sheet.zh-CN.md @@ -2,12 +2,14 @@ ## 使用 jvn workspace sheet <参数: ?> +__ --active <结构表名称> # 激活一个结构表 __ --new <结构表名称> # 创建结构表 __ --delete <结构表名称> # 删除结构表 __ --print-path <结构表名称> # 打印结构表路径 __ --list-all # 列出所有结构表 ## 别名 +__ -a <结构表名称> __ -n <结构表名称> __ -d <结构表名称> __ -p <结构表名称> diff --git a/resources/locales/jvn/cmds/workspace/sheet/en.yml b/resources/locales/jvn/cmds/workspace/sheet/en.yml index 4718afa..176e8cc 100644 --- a/resources/locales/jvn/cmds/workspace/sheet/en.yml +++ b/resources/locales/jvn/cmds/workspace/sheet/en.yml @@ -1,5 +1,7 @@ workspace_sheet: error: + sheet_name_required_for_active: | + Sheet name is required for `--active` sheet_name_required_for_new: | Sheet name is required for `--new` sheet_name_required_for_delete: | @@ -11,11 +13,13 @@ workspace_sheet: You can use `jvn helpdoc commands/workspace/sheet` to view usage. comp: + active: | + Activate a specified struct sheet list_all: | - List all structure sheets + List all struct sheets print_path: | - Print the file path of the specified structure sheet + Print the file path of the specified struct sheet new: | - Create a new structure sheet + Create a new struct sheet delete: | - Delete a structure sheet + Delete a struct sheet diff --git a/resources/locales/jvn/cmds/workspace/sheet/zh-CN.yml b/resources/locales/jvn/cmds/workspace/sheet/zh-CN.yml index 636a68f..5184791 100644 --- a/resources/locales/jvn/cmds/workspace/sheet/zh-CN.yml +++ b/resources/locales/jvn/cmds/workspace/sheet/zh-CN.yml @@ -1,5 +1,7 @@ workspace_sheet: error: + sheet_name_required_for_active: | + 对于符号 `--active`,需要显式指定 `结构表` 名称 sheet_name_required_for_new: | 对于符号 `--new`,需要显式指定 `结构表` 名称 sheet_name_required_for_delete: | @@ -11,6 +13,8 @@ workspace_sheet: 您可以使用 `jvn helpdoc commands/workspace/sheet` 来查看使用方式 comp: + active: | + 激活指定的结构表 list_all: | 列出所有结构表 print_path: | diff --git a/resources/locales/jvn/en.yml b/resources/locales/jvn/en.yml index 59d2a76..eed7ff8 100644 --- a/resources/locales/jvn/en.yml +++ b/resources/locales/jvn/en.yml @@ -68,7 +68,6 @@ prepare_error: %{error} error: | - Unknown error in preparation phase! %{error} local_workspace_not_found: | diff --git a/resources/locales/jvn/zh-CN.yml b/resources/locales/jvn/zh-CN.yml index 5fa559d..fbefb15 100644 --- a/resources/locales/jvn/zh-CN.yml +++ b/resources/locales/jvn/zh-CN.yml @@ -48,7 +48,6 @@ prepare_error: %{error} error: | - 命令在准备阶段发生错误! %{error} local_workspace_not_found: | diff --git a/src/cmds/arg/workspace_sheet.rs b/src/cmds/arg/workspace_sheet.rs index 7cf65e4..7115c17 100644 --- a/src/cmds/arg/workspace_sheet.rs +++ b/src/cmds/arg/workspace_sheet.rs @@ -8,6 +8,9 @@ pub struct JVWorkspaceSheetArgument { pub name: Option, + #[arg(short = 'a', long = "active")] + pub active: bool, + #[arg(short = 'n', long = "new")] pub new: bool, diff --git a/src/cmds/cmd/workspace_sheet.rs b/src/cmds/cmd/workspace_sheet.rs index 2154b43..e824d70 100644 --- a/src/cmds/cmd/workspace_sheet.rs +++ b/src/cmds/cmd/workspace_sheet.rs @@ -3,7 +3,9 @@ use crate::{ cmds::{ arg::workspace_sheet::JVWorkspaceSheetArgument, collect::workspace::JVWorkspaceCollect, - converter::make_sheet_error::MakeSheetErrorConverter, + converter::{ + make_sheet_error::MakeSheetErrorConverter, space_error::JVSpaceErrorConverter, + }, r#in::workspace_sheet::JVWorkspaceSheetInput, out::{none::JVNoneOutput, path::JVPathOutput, string_vcs::JVStringVecOutput}, }, @@ -31,8 +33,24 @@ async fn help_str() -> String { } async fn prepare(_args: &Arg, _ctx: &JVCommandContext) -> Result { - let input = match (_args.new, _args.delete, _args.list_all, _args.print_path) { - (true, false, false, false) => { + let input = match ( + _args.active, + _args.new, + _args.delete, + _args.list_all, + _args.print_path, + ) { + (true, false, false, false, false) => { + let name = _args.name.as_ref().ok_or_else(|| { + CmdPrepareError::Error( + t!("workspace_sheet.error.sheet_name_required_for_active") + .trim() + .to_string(), + ) + })?; + JVWorkspaceSheetInput::Active(name.clone()) + } + (false, true, false, false, false) => { let name = _args.name.as_ref().ok_or_else(|| { CmdPrepareError::Error( t!("workspace_sheet.error.sheet_name_required_for_new") @@ -42,7 +60,7 @@ async fn prepare(_args: &Arg, _ctx: &JVCommandContext) -> Result { + (false, false, true, false, false) => { let name = _args.name.as_ref().ok_or_else(|| { CmdPrepareError::Error( t!("workspace_sheet.error.sheet_name_required_for_delete") @@ -52,8 +70,8 @@ async fn prepare(_args: &Arg, _ctx: &JVCommandContext) -> Result JVWorkspaceSheetInput::ListAll, - (false, false, false, true) => { + (false, false, false, true, false) => JVWorkspaceSheetInput::ListAll, + (false, false, false, false, true) => { let name = _args.name.as_ref().ok_or_else(|| { CmdPrepareError::Error( t!("workspace_sheet.error.sheet_name_required_for_print_path") @@ -83,6 +101,11 @@ async fn collect(_args: &Arg, _ctx: &JVCommandContext) -> Result Result { match input { + JVWorkspaceSheetInput::Active(sheet_name) => { + if let Err(e) = collect.manager.edit_using_sheet_name(sheet_name).await { + return Err(JVSpaceErrorConverter::to_exec_error(e)); + } + } JVWorkspaceSheetInput::Add(sheet_name) => { if let Err(e) = collect.manager.make_sheet(sheet_name).await { return Err(MakeSheetErrorConverter::to_exec_error(e)); diff --git a/src/cmds/comp/workspace_sheet.rs b/src/cmds/comp/workspace_sheet.rs index d74f3c8..a0dd260 100644 --- a/src/cmds/comp/workspace_sheet.rs +++ b/src/cmds/comp/workspace_sheet.rs @@ -7,6 +7,8 @@ use crate::systems::comp::{context::CompletionContext, result::CompletionResult} pub fn comp(ctx: CompletionContext) -> CompletionResult { if ctx.current_word.starts_with('-') { return suggest!( + "-a" = t!("workspace_sheet.comp.active").trim(), + "--active" = t!("workspace_sheet.comp.active").trim(), "-A" = t!("workspace_sheet.comp.list_all").trim(), "--list-all" = t!("workspace_sheet.comp.list_all").trim(), "-p" = t!("workspace_sheet.comp.print_path").trim(), @@ -23,7 +25,9 @@ pub fn comp(ctx: CompletionContext) -> CompletionResult { return suggest!().into(); } - if ctx.previous_word == "--list-all" + if ctx.previous_word == "--active" + || ctx.previous_word == "-a" + || ctx.previous_word == "--list-all" || ctx.previous_word == "-A" || ctx.previous_word == "--print-path" || ctx.previous_word == "-p" diff --git a/src/cmds/in/workspace_sheet.rs b/src/cmds/in/workspace_sheet.rs index 78159ac..a1f33fd 100644 --- a/src/cmds/in/workspace_sheet.rs +++ b/src/cmds/in/workspace_sheet.rs @@ -1,4 +1,5 @@ pub enum JVWorkspaceSheetInput { + Active(String), Add(String), Delete(String), ListAll, -- cgit