diff --git a/cli-engine/src/output/human/mod.rs b/cli-engine/src/output/human/mod.rs index 2d5258f..70f1051 100644 --- a/cli-engine/src/output/human/mod.rs +++ b/cli-engine/src/output/human/mod.rs @@ -354,7 +354,9 @@ pub fn render_human_with_registry_selected( if let Some(data) = &envelope.data && let Some(custom) = registry.custom(schema_id) { - return custom.render(data); + let mut output = custom.render(data); + append_next_actions(&mut output, &envelope.next_actions); + return output; } match registry.columns(schema_id) { Some(columns) => { diff --git a/cli-engine/tests/custom_human_views.rs b/cli-engine/tests/custom_human_views.rs new file mode 100644 index 0000000..c44d8d3 --- /dev/null +++ b/cli-engine/tests/custom_human_views.rs @@ -0,0 +1,28 @@ +use cli_engine::{ + Envelope, HumanViewRegistry, NextAction, NextActionParam, render_human_with_registry_selected, +}; +use serde_json::json; + +#[test] +fn custom_human_output_appends_next_steps_footer() { + let mut registry = HumanViewRegistry::new(); + registry.register_func("shopping-cart", |_| "Cart: ready\n".to_owned()); + let envelope = + Envelope::success(json!({ "id": "cart-1" }), "shopping-cart").with_next_actions(vec![ + NextAction::new( + "shopping checkout complete --agree", + "Place the order", + ) + .with_param("cart-id", NextActionParam::value("cart-1")), + ]); + + let out = render_human_with_registry_selected(&envelope, ®istry, "shopping-cart", ""); + + assert!(out.starts_with("Cart: ready\n"), "{out}"); + assert!(out.contains("\nNext steps:\n"), "{out}"); + assert!( + out.contains("shopping checkout complete cart-1 --agree"), + "{out}" + ); + assert!(out.contains("Place the order"), "{out}"); +}