diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-09 23:19:55 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-09 23:19:55 +0800 |
| commit | 2f018e89c8584bc2bbca91054d0d5e96ed57e42d (patch) | |
| tree | 4cbacfab1a4d7a5db5ae1e87ef7719bc3f9e5737 /src/bin | |
| parent | ab2c87b785036a872e17eac771c65a4af88790e5 (diff) | |
Add JSON output support for share list and see commands
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/jv.rs | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/bin/jv.rs b/src/bin/jv.rs index de40b23..21ec126 100644 --- a/src/bin/jv.rs +++ b/src/bin/jv.rs @@ -92,6 +92,7 @@ use just_enough_vcs_cli::{ analyzer_result::{AnalyzerJsonResult, ModifiedType}, here::{HereJsonResult, HereJsonResultItem}, info::{InfoHistory, InfoJsonResult}, + share::{SeeShareResult, ShareItem, ShareListResult}, sheets::{SheetItem, SheetListJsonResult}, }, utils::{ @@ -730,6 +731,14 @@ struct ShareMappingArgs { /// Show raw output #[arg(short = 'r', long)] raw: bool, + + /// Show json output + #[arg(long = "json")] + json_output: bool, + + /// Show json output pretty + #[arg(long = "pretty")] + pretty: bool, } #[derive(Parser, Debug)] @@ -4751,7 +4760,7 @@ async fn jv_share(args: ShareMappingArgs) { if let (Some(args1), Some(args2), None) = (&args.args1, &args.args2, &args.args3) { // See mode if args1.trim() == "see" { - share_see(args2.to_string()).await; + share_see(args2.to_string(), args).await; return; } @@ -4814,6 +4823,21 @@ async fn share_list(args: ShareMappingArgs) { sorted_shares.insert(id.clone(), share); } + if args.json_output { + let share_list: Vec<ShareItem> = sorted_shares + .iter() + .map(|(share_id, share)| ShareItem { + share_id: share_id.clone(), + sharer: share.sharer.clone(), + description: share.description.clone(), + file_count: share.mappings.len(), + }) + .collect(); + let result = ShareListResult { share_list }; + print_json(result, args.pretty); + return; + } + if !args.raw { // Create table and insert information let mut table = SimpleTable::new(vec