From ac9e79512266242904715c179b0abde157856ad4 Mon Sep 17 00:00:00 2001 From: William Erik Baxter Date: Fri, 28 Mar 2025 18:17:54 -0500 Subject: [PATCH] Produce empty output for null input under -c The earlier version printed only the end tag . This version does so only if paths is non-empty. A new test verifies the behavior. --- files_to_prompt/cli.py | 2 +- tests/test_files_to_prompt.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/files_to_prompt/cli.py b/files_to_prompt/cli.py index 7eee04f..df28ebd 100644 --- a/files_to_prompt/cli.py +++ b/files_to_prompt/cli.py @@ -328,7 +328,7 @@ def cli( markdown, line_numbers, ) - if claude_xml: + if claude_xml and paths: writer("") if fp: fp.close() diff --git a/tests/test_files_to_prompt.py b/tests/test_files_to_prompt.py index 5268995..d550802 100644 --- a/tests/test_files_to_prompt.py +++ b/tests/test_files_to_prompt.py @@ -403,6 +403,18 @@ def test_paths_from_arguments_and_stdin(tmpdir): assert "test_dir2/file2.txt" in result.output assert "Contents of file2" in result.output +def test_empty_path_set(tmpdir): + runner = CliRunner() + with tmpdir.as_cwd(): + # Test empty path set + result = runner.invoke( + cli, + args=["-c"], + input="", + ) + assert result.exit_code == 0 + assert "" == result.output + @pytest.mark.parametrize("option", ("-m", "--markdown")) def test_markdown(tmpdir, option):