diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-27 06:20:10 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-27 06:20:10 +0800 |
| commit | a31cb962b99e96bda167be87dd37c2e2f82fea2f (patch) | |
| tree | c8182c97081492bc01cf7bfcacc4cd7a8fda45a3 /src/cmds/cmd | |
| parent | 94b7d7d80a0c2dd0884bed60659d65c5019f0839 (diff) | |
Add pretty output option to sheetdump command
Diffstat (limited to 'src/cmds/cmd')
| -rw-r--r-- | src/cmds/cmd/sheetdump.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/cmds/cmd/sheetdump.rs b/src/cmds/cmd/sheetdump.rs index 1945f44..fefa6d4 100644 --- a/src/cmds/cmd/sheetdump.rs +++ b/src/cmds/cmd/sheetdump.rs @@ -3,8 +3,10 @@ use std::any::TypeId; use crate::{ cmd_output, cmds::{ - arg::sheetdump::JVSheetdumpArgument, collect::sheetdump::JVSheetdumpCollect, - r#in::sheetdump::JVSheetdumpInput, out::mappings::JVMappingsOutput, + arg::sheetdump::JVSheetdumpArgument, + collect::sheetdump::JVSheetdumpCollect, + r#in::sheetdump::JVSheetdumpInput, + out::{mappings::JVMappingsOutput, mappings_pretty::JVMappingsPrettyOutput}, }, systems::cmd::{ cmd_system::JVCommandContext, @@ -28,7 +30,10 @@ fn help_str() -> String { } async fn prepare(args: &Arg, _ctx: &JVCommandContext) -> Result<In, CmdPrepareError> { - Ok(In { sort: args.sort }) + Ok(In { + sort: !args.no_sort, + pretty: !args.no_pretty, + }) } async fn collect(args: &Arg, _ctx: &JVCommandContext) -> Result<Collect, CmdPrepareError> { @@ -55,10 +60,15 @@ async fn exec( mappings_vec.sort(); } - let result = JVMappingsOutput { - mappings: mappings_vec, - }; - cmd_output!(JVMappingsOutput => result) + if input.pretty { + cmd_output!(JVMappingsPrettyOutput => JVMappingsPrettyOutput { + mappings: mappings_vec, + }) + } else { + cmd_output!(JVMappingsOutput => JVMappingsOutput { + mappings: mappings_vec, + }) + } } crate::command_template!(); |
