-
Notifications
You must be signed in to change notification settings - Fork 90
Warn that --output / --format are ignored under --tui (#220) #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+110
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """PR 3 of the #220-223 set (issue #220): warn that --output / --format | ||
| are no-ops under --tui. | ||
|
|
||
| The TUI ignores --output/--format (run_session_browser never receives them; | ||
| its export actions write to a fixed per-session path). Rather than silently | ||
| ignoring, the CLI now warns — mirroring the --expand-paths/--filter-path | ||
| ignored-flag warnings. These tests drive the warn via an empty projects | ||
| dir so the TUI returns early ("No projects ...") without launching Textual. | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from click.testing import CliRunner | ||
|
|
||
| from claude_code_log.cli import main | ||
|
|
||
|
|
||
| def _empty_projects(tmp_path: Path) -> Path: | ||
| d = tmp_path / "projects" | ||
| d.mkdir() | ||
| return d | ||
|
|
||
|
|
||
| class TestTuiOutputWarn: | ||
| def setup_method(self): | ||
| self.runner = CliRunner() | ||
|
|
||
| def test_warns_on_output_under_tui(self, tmp_path: Path): | ||
| r = self.runner.invoke( | ||
| main, | ||
| ["--tui", "--projects-dir", str(_empty_projects(tmp_path)), "-o", "x.md"], | ||
| ) | ||
| assert r.exit_code == 0, r.output | ||
| assert "ignored in --tui mode" in r.stderr | ||
|
|
||
| def test_warns_on_explicit_format_under_tui(self, tmp_path: Path): | ||
| r = self.runner.invoke( | ||
| main, | ||
| [ | ||
| "--tui", | ||
| "--projects-dir", | ||
| str(_empty_projects(tmp_path)), | ||
| "-f", | ||
| "markdown", | ||
| ], | ||
| ) | ||
| assert r.exit_code == 0, r.output | ||
| assert "ignored in --tui mode" in r.stderr | ||
|
|
||
| def test_no_warn_under_tui_without_output_or_format(self, tmp_path: Path): | ||
| r = self.runner.invoke( | ||
| main, ["--tui", "--projects-dir", str(_empty_projects(tmp_path))] | ||
| ) | ||
| assert r.exit_code == 0, r.output | ||
| assert "ignored in --tui mode" not in r.stderr | ||
|
|
||
| def test_warn_goes_to_stderr_not_stdout(self, tmp_path: Path): | ||
| r = self.runner.invoke( | ||
| main, | ||
| ["--tui", "--projects-dir", str(_empty_projects(tmp_path)), "-o", "x.md"], | ||
| ) | ||
| assert "ignored in --tui mode" not in r.stdout | ||
| assert "ignored in --tui mode" in r.stderr | ||
|
|
||
| def test_conflicting_output_format_under_tui_warns_not_errors(self, tmp_path: Path): | ||
| """A `-o x.md -f html` conflict (#222) must NOT hard-error under --tui: | ||
| both flags are ignored there, so we warn and let the TUI proceed | ||
| rather than blocking on a conflict the user can't act on (#220).""" | ||
| r = self.runner.invoke( | ||
| main, | ||
| [ | ||
| "--tui", | ||
| "--projects-dir", | ||
| str(_empty_projects(tmp_path)), | ||
| "-o", | ||
| "x.md", | ||
| "-f", | ||
| "html", | ||
| ], | ||
| ) | ||
| assert r.exit_code == 0, r.output | ||
| assert "ignored in --tui mode" in r.stderr | ||
| assert "conflicts" not in r.output | ||
|
|
||
| def test_no_warn_when_not_tui(self, tmp_path: Path): | ||
| """A normal (non-TUI) `-o` conversion must not emit the TUI warning.""" | ||
| src = tmp_path / "s.jsonl" | ||
| src.write_text("", encoding="utf-8") # empty → no messages, still converts | ||
| out = tmp_path / "out.md" | ||
| r = self.runner.invoke(main, [str(src), "-o", str(out)]) | ||
| assert "ignored in --tui mode" not in r.output | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Add an exit-code assertion in the non-TUI baseline test.
Line 90 should also assert
r.exit_code == 0; otherwise this test can pass even when invocation fails for unrelated reasons.🤖 Prompt for AI Agents