Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates cut’s argument/range parsing diagnostics to better match GNU cut, including mode-aware messages (fields vs byte/character positions) and “usage”-style failures that include the “Try --help” hint.
Changes:
- Add a GNU-aligned range-list parser in
cutto produce more specific diagnostics (empty/invalid/decreasing/no-endpoint/too-large). - Switch several error paths from
USimpleErrortoUUsageErrorso they’re treated as usage errors (with the help hint). - Update
cut’s locale strings and expand tests to assert the new diagnostic wording.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/by-util/test_cut.rs | Adjusts existing assertions and adds a new test matrix for GNU-like range/option diagnostics. |
| src/uucore/src/lib/features/ranges.rs | Exposes Range::merge publicly so cut can merge parsed ranges after custom parsing. |
| src/uu/cut/src/cut.rs | Implements mode-aware range parsing + updates multiple error paths to UUsageError. |
| src/uu/cut/locales/fr-FR.ftl | Updates French diagnostic strings and adds new range-related message keys. |
| src/uu/cut/locales/en-US.ftl | Updates English diagnostic strings and adds new range-related message keys. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
GNU testsuite comparison: |
Produce GNU's mode-aware messages (fields vs byte/character positions), distinguish empty/invalid/decreasing/no-endpoint ranges, and align the usage errors, all with the 'Try --help' hint.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/uu/cut/src/cut.rs:66
- Doc comment mentions a
-Foption for field mode, but this utility only defines-f/--fields(no-F). This can mislead future maintainers when interpreting the mode-specific diagnostics logic.
/// GNU's range-list diagnostics, worded for field mode (`-f`/`-F`) or for
/// byte/character mode (`-b`/`-c`).
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | du_wide_tree[(5000, 500)] |
19.3 ms | 20.2 ms | -4.52% |
| ⚡ | Simulation | numfmt_to_si[10000] |
94.4 ms | 91.3 ms | +3.4% |
| ⚡ | Simulation | numfmt_round_modes[("up", 10000)] |
95.8 ms | 92.7 ms | +3.35% |
| ⚡ | Simulation | numfmt_large_numbers_si[10000] |
100.3 ms | 97.2 ms | +3.2% |
| ⚡ | Simulation | numfmt_padding[(10000, 50)] |
100.2 ms | 97.1 ms | +3.2% |
| ⚡ | Simulation | numfmt_to_si_precision[10000] |
97.5 ms | 94.6 ms | +3.11% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing cut-diag (ce4cf44) with main (9516e99)
Footnotes
-
50 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Produce GNU's mode-aware messages (fields vs byte/character positions),
distinguish empty/invalid/decreasing/no-endpoint ranges, and align the
usage errors, all with the 'Try --help' hint.
Should make test tests/cut/cut.pl pass
Stack created with GitHub Stacks CLI • Give Feedback 💬