1+ use super :: json_output:: { print_pretty_json, to_json_value} ;
12use crate :: {
23 acp:: { load_acp_checkpoints, load_acp_events} ,
34 cli:: AcpCommand ,
@@ -16,10 +17,7 @@ pub(super) fn run(command: AcpCommand) -> anyhow::Result<()> {
1617
1718 let events = load_acp_events ( & memory, session. as_deref ( ) , limit) ?;
1819 if json {
19- println ! (
20- "{}" ,
21- serde_json:: to_string_pretty( & build_acp_events_json( & events) ?) ?
22- ) ;
20+ print_pretty_json ( & build_acp_events_json ( & events) ?) ?;
2321 } else {
2422 for event in events {
2523 let session = event
@@ -45,10 +43,7 @@ pub(super) fn run(command: AcpCommand) -> anyhow::Result<()> {
4543
4644 let checkpoints = load_acp_checkpoints ( & memory, & session) ?;
4745 if json {
48- println ! (
49- "{}" ,
50- serde_json:: to_string_pretty( & build_acp_checkpoints_json( & checkpoints) ?) ?
51- ) ;
46+ print_pretty_json ( & build_acp_checkpoints_json ( & checkpoints) ?) ?;
5247 } else if checkpoints. is_empty ( ) {
5348 println ! ( "no checkpoints for session {}" , session) ;
5449 } else {
@@ -74,13 +69,13 @@ pub(super) fn run(command: AcpCommand) -> anyhow::Result<()> {
7469}
7570
7671fn build_acp_events_json ( events : & [ serde_json:: Value ] ) -> anyhow:: Result < serde_json:: Value > {
77- Ok ( serde_json :: to_value ( events) ? )
72+ to_json_value ( events)
7873}
7974
8075fn build_acp_checkpoints_json (
8176 checkpoints : & [ serde_json:: Value ] ,
8277) -> anyhow:: Result < serde_json:: Value > {
83- Ok ( serde_json :: to_value ( checkpoints) ? )
78+ to_json_value ( checkpoints)
8479}
8580
8681#[ cfg( test) ]
0 commit comments