@@ -321,6 +321,62 @@ pub fn localized_help_template_with_colors(
321321 template
322322}
323323
324+ /// Create a localized help template for true/false commands which starts with Usage:
325+ /// This ensures the format matches GNU coreutils where Usage: appears first
326+ pub fn true_false_help_template ( util_name : & str ) -> clap:: builder:: StyledStr {
327+ use std:: io:: IsTerminal ;
328+
329+ // Determine if colors should be enabled - same logic as configure_localized_command
330+ let colors_enabled = if std:: env:: var ( "NO_COLOR" ) . is_ok ( ) {
331+ false
332+ } else if std:: env:: var ( "CLICOLOR_FORCE" ) . is_ok ( ) || std:: env:: var ( "FORCE_COLOR" ) . is_ok ( ) {
333+ true
334+ } else {
335+ IsTerminal :: is_terminal ( & std:: io:: stdout ( ) )
336+ && std:: env:: var ( "TERM" ) . unwrap_or_default ( ) != "dumb"
337+ } ;
338+
339+ true_false_help_template_with_colors ( util_name, colors_enabled)
340+ }
341+
342+ /// Create a localized help template for true/false commands with explicit color control
343+ pub fn true_false_help_template_with_colors (
344+ util_name : & str ,
345+ colors_enabled : bool ,
346+ ) -> clap:: builder:: StyledStr {
347+ use std:: fmt:: Write ;
348+
349+ // Ensure localization is initialized for this utility
350+ let _ = crate :: locale:: setup_localization ( util_name) ;
351+
352+ // Get the localized "Usage" label
353+ let usage_label = crate :: locale:: translate!( "common-usage" ) ;
354+
355+ // Create a styled template
356+ let mut template = clap:: builder:: StyledStr :: new ( ) ;
357+
358+ // Add the basic template parts
359+ write ! ( template, "{{before-help}}" ) . unwrap ( ) ;
360+
361+ // Add styled usage header (bold + underline like clap's default)
362+ if colors_enabled {
363+ write ! (
364+ template,
365+ "\x1b [1m\x1b [4m{usage_label}:\x1b [0m {{usage}}\n \n "
366+ )
367+ . unwrap ( ) ;
368+ } else {
369+ write ! ( template, "{usage_label}: {{usage}}\n \n " ) . unwrap ( ) ;
370+ }
371+
372+ writeln ! ( template, "{{about-with-newline}}" ) . unwrap ( ) ;
373+
374+ // Add the rest
375+ write ! ( template, "{{all-args}}{{after-help}}" ) . unwrap ( ) ;
376+
377+ template
378+ }
379+
324380/// Used to check if the utility is the second argument.
325381/// Used to check if we were called as a multicall binary (`coreutils <utility>`)
326382pub fn get_utility_is_second_arg ( ) -> bool {
0 commit comments