Skip to content

feat: add rtk wc command for compact word/line/byte counts#175

Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom
heAdz0r:feat/wc-command
Feb 18, 2026
Merged

feat: add rtk wc command for compact word/line/byte counts#175
pszymkowiak merged 1 commit intortk-ai:masterfrom
heAdz0r:feat/wc-command

Conversation

@heAdz0r
Copy link
Contributor

@heAdz0r heAdz0r commented Feb 17, 2026

Summary

  • Adds rtk wc subcommand that compresses wc output (strips padding, shortens paths, returns bare numbers for single-flag modes)
  • Single file: 30 96 978 file.py30L 96W 978B
  • Multi-file: strips common path prefix, replaces "total" with Σ
  • Single-flag modes (-l, -w, -c, -m): returns bare number

Changes

File Change
src/wc_cmd.rs New module: filter logic, mode detection, common prefix stripping, 15 unit tests
src/main.rs +12 lines: mod wc_cmd, Wc enum variant, dispatch handler

No hooks, docs, or init template changes — this PR is implementation-only.

Token savings examples

Command Raw output RTK output Savings
wc file.py 30 96 978 scripts/find_duplicate_attrs.py 30L 96W 978B ~75%
wc -l file.py 30 scripts/find_duplicate_attrs.py 30 ~90%
wc -l src/*.rs 10+ lines with padded paths compact table, common prefix stripped ~60%

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --all-targets clean (no new warnings)
  • cargo test wc_cmd — 15/15 tests pass
  • Manual test: rtk wc src/main.rs, rtk wc -l src/*.rs

🤖 Generated with Claude Code

Adds a new `wc` subcommand that compresses wc output by:
- Stripping alignment padding: `      30      96     978 file.py` → `30L 96W 978B`
- Removing common path prefixes in multi-file output
- Returning bare numbers for single-flag modes (-l, -w, -c, -m)
- Showing Σ totals instead of verbose "total" lines

Includes 15 unit tests covering single/multi-file, stdin, all flag
modes, and common prefix detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@heAdz0r
Copy link
Contributor Author

heAdz0r commented Feb 17, 2026

CI note: Documentation Validation failure is pre-existing

The Documentation Validation / validate check fails with:

❌ README.md ne mentionne pas version 0.20.1

This is not caused by this PR — the same check fails on master itself:

577e082 (master HEAD) → Documentation Validation: failure
0b34772 (master~1)    → Documentation Validation: failure

The issue is that README.md was not updated after the 0.20.1 release. This PR only adds src/wc_cmd.rs and 12 lines to src/main.rs — no docs touched.

@pszymkowiak
Copy link
Collaborator

  • cargo fmt --all --check ✅
  • cargo clippy --all-targets ✅ (2 minor map_or → is_some_and suggestions, not introduced by this PR)
  • cargo test wc_cmd — 15/15 ✅
  • Manual test single file: wc src/main.rs → 1437L 4198W 44986B ✅
  • Manual test multi-file: wc -l src/*.rs → paths stripped, common prefix removed, Σ 22468 total ✅

Minor nit (non-blocking): Clippy suggests replacing parts.last().map_or(false, ...) with parts.last().is_some_and(...) in two places (lines 205 and 239). Feel free to fix or leave as-is.

@pszymkowiak pszymkowiak merged commit 393fa5b into rtk-ai:master Feb 18, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments