Description
echo '{"cpu": 2048}' | jsontohcl2 - --fragment --dry-run
# → error: argument --dry-run: not allowed with argument --fragment
--fragment alone works fine and already outputs to stdout (same behavior as --dry-run), so the restriction is unexpected.
Root Cause
In cli/json_to_hcl.py (lines 138-160), all four flags (--diff, --dry-run, --semantic-diff, --fragment) are in a single add_mutually_exclusive_group(). This was intentional (test at line 247 validates it with "Fix #5" comment), but the grouping is overly broad.
--diff and --semantic-diff are properly exclusive (different comparison modes requiring different inputs). But --fragment is a conversion mode (how to convert), not an output mode (where to write). Combining --fragment --dry-run is redundant since --fragment already outputs to stdout, but it shouldn't be an error.
Expected Behavior
--fragment --dry-run should either work (producing the same output as --fragment alone) or --fragment should be an orthogonal flag separate from the output mode group.
Workaround
Use --fragment without --dry-run — the output is identical.
Suggested Fix
Move --fragment out of the mutually exclusive group and make it an orthogonal conversion-mode flag. Keep --diff, --dry-run, --semantic-diff in the exclusive group as proper output modes.
Description
--fragmentalone works fine and already outputs to stdout (same behavior as--dry-run), so the restriction is unexpected.Root Cause
In
cli/json_to_hcl.py(lines 138-160), all four flags (--diff,--dry-run,--semantic-diff,--fragment) are in a singleadd_mutually_exclusive_group(). This was intentional (test at line 247 validates it with "Fix #5" comment), but the grouping is overly broad.--diffand--semantic-diffare properly exclusive (different comparison modes requiring different inputs). But--fragmentis a conversion mode (how to convert), not an output mode (where to write). Combining--fragment --dry-runis redundant since--fragmentalready outputs to stdout, but it shouldn't be an error.Expected Behavior
--fragment --dry-runshould either work (producing the same output as--fragmentalone) or--fragmentshould be an orthogonal flag separate from the output mode group.Workaround
Use
--fragmentwithout--dry-run— the output is identical.Suggested Fix
Move
--fragmentout of the mutually exclusive group and make it an orthogonal conversion-mode flag. Keep--diff,--dry-run,--semantic-diffin the exclusive group as proper output modes.