Repository navigation
fix(ls): suppress summary line when stdout is piped - #503
Conversation
|
LGTM — clean fix, well tested. Build passes, 35 ls tests pass, manual verification confirms:
Minor nit (non-blocking): @aeppling for merge. |
|
Thanks for the review! Applied the Also rebased on latest Side note: we noticed a pre-existing compilation error on |
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
rtk ls | wc -l returned N+2 instead of N because the summary line (📊 X files, Y dirs) and blank line were always written to stdout. Now uses std::io::stdout().is_terminal() to suppress the summary when piped, following standard Unix convention (ls, grep, find all do this). Fixes #482 Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Ousama Ben Younes <[email protected]>
Avoids one allocation since entries is not used after the if/else. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Ousama Ben Younes <[email protected]>
Fixes Documentation Validation CI check (main.rs=64, ARCHITECTURE.md was 60). Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Ousama Ben Younes <[email protected]>
|
Rebased on |
Summary
rtk ls | wc -lreturned N+2 instead of N because the📊summary line and blank line were always on stdoutstd::io::stdout().is_terminal()to suppress summary when pipedls,grep,findall suppress metadata when pipedFixes #482
Before
After
Changes
compact_ls()now returns(entries, summary)tuple instead of singleStringrun()only prints summary whenstdout().is_terminal()is truertk gain) only counts what is actually sent to stdoutTests added
test_entries_no_summary— entries never contain the📊linetest_pipe_line_count— simulates| wc -l, verifies exact count matches files+dirsTest plan
cargo test ls::tests— 35 tests pass (including 2 new)cargo test— 766 passed, 0 failedrtk ls src/ | wc -l=ls src/ | wc -l(both 61)rtk ls src/in terminal still shows summary🤖 Generated with Claude Code