Skip to content

fix(cli): reject repeated --out/--render/--draw instead of dropping paths - #136

Open
farisbasha wants to merge 1 commit into
wrong-nebula:mainfrom
farisbasha:fix-cli-repeated-out
Open

farisbasha wants to merge 1 commit into
wrong-nebula:mainfrom
farisbasha:fix-cli-repeated-out

Conversation

@farisbasha

Copy link
Copy Markdown
Contributor

Problem

The CLI keeps only the last value of a repeated output flag, without a warning:

echo 'a = box(1,1,1)' | forma eval --out a.stl --out b.glb
# exit 0, only b.glb is written; a.stl is silently dropped

The same happens for --render, --draw, and --out on forma render / forma draw. An extra input file is already rejected ("only one script file is accepted"), so a dropped output path is the odd one out, and an agent that asks for two formats this way gets one without noticing.

Fix

Output paths are set through a small set_path_once helper. A second value for the same output exits with code 2 (invalid CLI usage) before anything is evaluated or written:

ERR: --out given more than once ('a.stl' and 'b.glb'); each output takes one path

Using --out, --render and --draw once each together still works.

Tests

  • New repeated_output_flags_are_rejected_instead_of_dropped in crates/forma-cli/tests/cli_exit_codes.rs: repeated --out / -o / --render / --draw and forma render --out exit 2 and write nothing; one of each flag still writes all three files. It fails on main and passes with the change.
  • CI command cargo test --locked --release -p forma-core -p forma-lang -p forma-cli -p forma-mcp -p forma-server -- --skip test_10000_fuzzed_modeling_operations_zero_crashes_zero_nans: 158 passed, 0 failed (Linux).

This PR was prepared with AI assistance (Claude).

…aths

A second --out (or --render/--draw) replaced the first one, so
`forma eval --out a.stl --out b.glb` wrote only b.glb and said nothing.
Exit 2 with both paths instead, like an extra input file already does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant