Repository navigation
feat(true,false): print Usage: line before the description in --help - #12815
koopatroopa787 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds GNU-aligned help output for true/false by moving the “Usage:” synopsis ahead of the description and overriding the usage synopsis text, with new tests asserting the behavior.
Changes:
- Introduce a
localized_help_template_usage_firsthelp template variant inuucore - Override
true/falseusage strings via localized*-usagemessages andoverride_usage - Add integration tests asserting
--helpstarts with the expected usage synopsis
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/by-util/test_true.rs | Adds a test asserting true --help begins with the expected usage synopsis |
| tests/by-util/test_false.rs | Adds a test asserting false --help begins with the expected usage synopsis |
| src/uucore/src/lib/lib.rs | Adds a “usage first” localized help template and refactors color detection into a helper |
| src/uu/true/src/true.rs | Switches to usage-first template and overrides usage with a localized string |
| src/uu/true/locales/fr-FR.ftl | Adds localized true-usage string |
| src/uu/true/locales/en-US.ftl | Adds English true-usage string |
| src/uu/false/src/false.rs | Switches to usage-first template and overrides usage with a localized string |
| src/uu/false/locales/fr-FR.ftl | Adds localized false-usage string |
| src/uu/false/locales/en-US.ftl | Adds English false-usage string |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // GNU's `true --help` starts with a "Usage:" line; ensure ours does too. | ||
| let result = new_ucmd!().args(&["--help"]).succeeds(); | ||
| assert!( | ||
| result | ||
| .stdout_str() | ||
| .starts_with("Usage: true [ignored command line arguments]") | ||
| ); |
| // GNU's `false --help` starts with a "Usage:" line; ensure ours does too. | ||
| let result = new_ucmd!().args(&["--help"]).fails(); | ||
| assert!( | ||
| result | ||
| .stdout_str() | ||
| .starts_with("Usage: false [ignored command line arguments]") | ||
| ); |
| /// Determine whether colored output should be used, based on the same | ||
| /// environment variables and TTY checks as `configure_localized_command`. | ||
| fn detect_colors_enabled() -> bool { | ||
| use std::io::IsTerminal; | ||
|
|
||
| // Determine if colors should be enabled - same logic as configure_localized_command | ||
| let colors_enabled = if std::env::var("NO_COLOR").is_ok() { | ||
| if std::env::var("NO_COLOR").is_ok() { | ||
| false | ||
| } else if std::env::var("CLICOLOR_FORCE").is_ok() || std::env::var("FORCE_COLOR").is_ok() { | ||
| true | ||
| } else { | ||
| IsTerminal::is_terminal(&std::io::stdout()) | ||
| && std::env::var("TERM").unwrap_or_default() != "dumb" | ||
| }; | ||
|
|
||
| localized_help_template_with_colors(util_name, colors_enabled) | ||
| } | ||
| } |
Merging this PR will degrade performance by 28.41%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
GNU testsuite comparison: |
4dace34 to
ce69743
Compare
|
the CI has been failing on this one for a while, could you please have a look? otherwise, i will close it, thanks |
|
no news since my last ping, closing. reopen whenever you want to continue, thanks |
true --helpandfalse --helpnow print theUsage:line first, as GNU does. Addedlocalized_help_template_usage_first()in uucore (other utilities keep the existing order) andtrue-usage/false-usagestrings, plus a test for each.Fixes #10279