@@ -520,48 +520,59 @@ pub fn cli() -> Command {
520520    }  else  { 
521521        "cargo [OPTIONS] [COMMAND]\n        cargo [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]..." 
522522    } ; 
523+ 
524+     let  styles = { 
525+         use  clap:: builder:: styling:: * ; 
526+         Styles :: styled ( ) 
527+             . header ( AnsiColor :: Green . on_default ( )  | Effects :: BOLD ) 
528+             . usage ( AnsiColor :: Green . on_default ( )  | Effects :: BOLD ) 
529+             . literal ( AnsiColor :: Blue . on_default ( )  | Effects :: BOLD ) 
530+             . placeholder ( AnsiColor :: Cyan . on_default ( ) ) 
531+             . error ( AnsiColor :: Red . on_default ( ) ) 
532+             . valid ( AnsiColor :: Blue . on_default ( )  | Effects :: BOLD ) 
533+             . invalid ( AnsiColor :: Yellow . on_default ( ) ) 
534+     } ; 
535+ 
523536    Command :: new ( "cargo" ) 
524537        // Subcommands all count their args' display order independently (from 0), 
525538        // which makes their args interspersed with global args. This puts global args last. 
526539        // 
527540        // We also want these to come before auto-generated `--help` 
528541        . next_display_order ( 800 ) 
529542        . allow_external_subcommands ( true ) 
530-         // Doesn't mix well with our list of common cargo commands.  See clap-rs/clap#3108 for 
531-         // opening clap up to allow us to style our help template 
532-         . disable_colored_help ( true ) 
543+         . styles ( styles) 
533544        // Provide a custom help subcommand for calling into man pages 
534545        . disable_help_subcommand ( true ) 
535546        . override_usage ( usage) 
536-         . help_template ( 
547+         . help_template ( color_print :: cstr! ( 
537548            "\  
538549 Rust's package manager
539550
540- Usage:  {usage} 
551+ <green,bold> Usage:</> <blue,bold> {usage}</> 
541552
542- Options: 
553+ <green,bold> Options:</> 
543554{options} 
544555
545- Some common cargo commands are (see all commands with --list): 
546-     build, b     Compile the current package 
547-     check, c     Analyze the current package and report errors, but don't build object files 
548-     clean       Remove the target directory 
549-     doc, d       Build this package's and its dependencies' documentation 
550-     new         Create a new cargo package 
551-     init        Create a new cargo package in an existing directory 
552-     add         Add dependencies to a manifest file 
553-     remove      Remove dependencies from a manifest file 
554-     run, r       Run a binary or example of the local package 
555-     test, t      Run the tests 
556-     bench       Run the benchmarks 
557-     update      Update dependencies listed in Cargo.lock 
558-     search      Search registry for crates 
559-     publish     Package and upload this package to the registry 
560-     install     Install a Rust binary. Default location is $HOME/.cargo/bin 
561-     uninstall   Uninstall a Rust binary 
562- 
563- See 'cargo help <command>' for more information on a specific command.\n " , 
564-         ) 
556+ Some common cargo commands are (see all commands with '<blue,bold> --list</>' ): 
557+     <blue,bold> build</>, <blue,bold>b</>     Compile the current package 
558+     <blue,bold> check</>, <blue,bold>c</>     Analyze the current package and report errors, but don't build object files 
559+     <blue,bold> clean</>        Remove the target directory 
560+     <blue,bold> doc</>, <blue,bold>d</>       Build this package's and its dependencies' documentation 
561+     <blue,bold> new</>          Create a new cargo package 
562+     <blue,bold> init</>         Create a new cargo package in an existing directory 
563+     <blue,bold> add</>          Add dependencies to a manifest file 
564+     <blue,bold> remove</>       Remove dependencies from a manifest file 
565+     <blue,bold> run</>, <blue,bold>r</>       Run a binary or example of the local package 
566+     <blue,bold> test</>, <blue,bold>t</>      Run the tests 
567+     <blue,bold> bench</>        Run the benchmarks 
568+     <blue,bold> update</>       Update dependencies listed in Cargo.lock 
569+     <blue,bold> search</>       Search registry for crates 
570+     <blue,bold> publish</>      Package and upload this package to the registry 
571+     <blue,bold> install</>      Install a Rust binary. Default location is $HOME/.cargo/bin 
572+     <blue,bold> uninstall</>    Uninstall a Rust binary 
573+ 
574+ See '<blue,bold> cargo help << command>></ >' for more information on a specific command.\n " , 
575+         ) ) 
565576        . arg ( flag ( "version" ,  "Print version info and exit" ) . short ( 'V' ) ) 
566577        . arg ( flag ( "list" ,  "List installed commands" ) ) 
567578        . arg ( opt ( "explain" ,  "Run `rustc --explain CODE`" ) . value_name ( "CODE" ) ) 
0 commit comments