From 20f718ba08a891303658c22fb91feaed6e9fb6a1 Mon Sep 17 00:00:00 2001 From: Jordan Noone Date: Sat, 29 Aug 2026 16:08:36 -0700 Subject: [PATCH] Reject unsupported KCL format output --- src/cmd_kcl.rs | 2 ++ src/tests.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/cmd_kcl.rs b/src/cmd_kcl.rs index bbfafc7a..5189c6c3 100644 --- a/src/cmd_kcl.rs +++ b/src/cmd_kcl.rs @@ -285,6 +285,8 @@ impl crate::cmd::Command for CmdKclFormat { if format == &FormatOutput::Json { // Print the formatted file to stdout as json. writeln!(ctx.io.out, "{}", serde_json::to_string_pretty(&program)?)?; + } else { + anyhow::bail!("the `{format}` output format is not supported for `zoo kcl format`"); } } else { // Print the formatted file to stdout. diff --git a/src/tests.rs b/src/tests.rs index 8791b42f..a0019f95 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -682,6 +682,15 @@ cli_tests! { .stdout_contains(r#""mass": 0.000858"#) } + format_kcl_rejects_unsupported_output(_ctx) => { + TestItem::new( + "format kcl rejects unsupported output", + svec!["zoo", "kcl", "format", "tests/gear.kcl", "--format", "yaml"], + ) + .stderr_contains("the `yaml` output format is not supported for `zoo kcl format`") + .exit_code(1) + } + snapshot_a_kcl_file_as_png(_ctx) => { TestItem::new( "snapshot a kcl file as png",