Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/toon_format/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def decode_toon_to_json(
options = DecodeOptions(indent=indent, strict=strict)
data = decode(toon_text, options)

return json.dumps(data, indent=2, ensure_ascii=False)
return json.dumps(data, indent=indent, ensure_ascii=False)


if __name__ == "__main__":
Expand Down
12 changes: 12 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ def test_no_strict_option(self, tmp_path):
result = main()
assert result == 0

def test_decode_indent_option_affects_output(self, tmp_path):
"""Ensure --indent controls the JSON formatting."""
input_file = tmp_path / "input.toon"
input_file.write_text("outer:\n inner: 1")

with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
with patch("sys.argv", ["toon", str(input_file), "--decode", "--indent", "4"]):
result = main()
assert result == 0
output = mock_stdout.getvalue()
assert ' "inner": 1' in output

def test_error_file_not_found(self):
"""Test error when input file doesn't exist."""
with patch("sys.stderr", new_callable=StringIO) as mock_stderr:
Expand Down
Loading