Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cli-engine/src/output/human/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
28 changes: 28 additions & 0 deletions cli-engine/tests/custom_human_views.rs
Original file line number Diff line number Diff line change
@@ -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 <cart-id> --agree",
"Place the order",
)
.with_param("cart-id", NextActionParam::value("cart-1")),
]);

let out = render_human_with_registry_selected(&envelope, &registry, "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}");
}