Skip to content

feat(true,false): print Usage: line before the description in --help - #12815

Closed
koopatroopa787 wants to merge 1 commit into
uutils:mainfrom
koopatroopa787:true-false-usage-first
Closed

koopatroopa787 wants to merge 1 commit into
uutils:mainfrom
koopatroopa787:true-false-usage-first

Conversation

@koopatroopa787

@koopatroopa787 koopatroopa787 commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

true --help and false --help now print the Usage: line first, as GNU does. Added localized_help_template_usage_first() in uucore (other utilities keep the existing order) and true-usage/false-usage strings, plus a test for each.

Fixes #10279

Copilot AI review requested due to automatic review settings June 12, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_first help template variant in uucore
  • Override true/false usage strings via localized *-usage messages and override_usage
  • Add integration tests asserting --help starts 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.

Comment on lines +35 to +41
// 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]")
);
Comment on lines +32 to +38
// 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]")
);
Comment thread src/uucore/src/lib/lib.rs
Comment on lines +301 to 314
/// 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)
}
}
@codspeed

codspeed Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 28.41%

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 318 untouched benchmarks
⏩ 130 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation three_39_bit_primes 377.6 ms 892.5 ms -57.69%
❌ Simulation mv_force_overwrite 147.8 ms 182.8 ms -19.14%
⚡ Simulation five_38_bit_primes 1.8 s 1.7 s +7.26%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing koopatroopa787:true-false-usage-first (ce69743) with main (3f92f51)

Open in CodSpeed

Footnotes

  1. 130 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. ↩

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/tail/truncate. tests/tail/truncate is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/timeout/timeout-group (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Skip an intermittent issue tests/cut/bounded-memory (was skipped on 'main', now failing)
Skip an intermittent issue tests/tail/tail-n0f (was skipped on 'main', now failing)

@koopatroopa787
koopatroopa787 force-pushed the true-false-usage-first branch from 4dace34 to ce69743 Compare October 5, 2026 13:49
Copilot AI balanced review requested due to automatic review settings October 5, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sylvestre

Copy link
Copy Markdown
Contributor

the CI has been failing on this one for a while, could you please have a look? otherwise, i will close it, thanks

@sylvestre

Copy link
Copy Markdown
Contributor

no news since my last ping, closing. reopen whenever you want to continue, thanks

@sylvestre sylvestre closed this Nov 27, 2026
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.

missing "Usage:" in true/false

3 participants