@@ -2122,10 +2122,15 @@ pub fn command_with_help_with_options(render_options: RenderOptions) -> clap::Co
21222122}
21232123
21242124/// Apply custom help formatting to a clap Command to match the JS CLI output.
2125- fn apply_custom_help ( cmd : clap:: Command , _render_options : RenderOptions ) -> clap:: Command {
2125+ fn apply_custom_help ( cmd : clap:: Command , render_options : RenderOptions ) -> clap:: Command {
21262126 let after_help = help:: render_help_doc ( & help:: top_level_help_doc ( ) ) ;
2127+ let header = if render_options. show_header {
2128+ format ! ( "{}\n \n " , vite_shared:: header:: vite_plus_header( ) )
2129+ } else {
2130+ String :: new ( )
2131+ } ;
21272132 let options_heading = help:: render_heading ( "Options" ) ;
2128- let help_template = format ! ( "{{after-help}}\n {options_heading}\n {{options}}\n " ) ;
2133+ let help_template = format ! ( "{header}{ {after-help}}\n {options_heading}\n {{options}}\n " ) ;
21292134
21302135 cmd. after_help ( after_help) . help_template ( help_template)
21312136}
@@ -2151,7 +2156,10 @@ pub fn try_parse_args_from_with_options(
21512156
21522157#[ cfg( test) ]
21532158mod tests {
2154- use super :: { has_flag_before_terminator, should_force_global_delegate} ;
2159+ use super :: {
2160+ RenderOptions , command_with_help_with_options, has_flag_before_terminator,
2161+ should_force_global_delegate,
2162+ } ;
21552163
21562164 #[ test]
21572165 fn detects_flag_before_option_terminator ( ) {
@@ -2184,4 +2192,22 @@ mod tests {
21842192 assert ! ( !should_force_global_delegate( "lint" , & [ "src/index.ts" . to_string( ) ] ) ) ;
21852193 assert ! ( !should_force_global_delegate( "fmt" , & [ "--check" . to_string( ) ] ) ) ;
21862194 }
2195+
2196+ #[ test]
2197+ fn top_level_help_includes_header_when_enabled ( ) {
2198+ let help = command_with_help_with_options ( RenderOptions { show_header : true } )
2199+ . render_help ( )
2200+ . to_string ( ) ;
2201+
2202+ assert ! ( help. starts_with( "VITE+ - The Unified Toolchain for the Web\n \n " ) ) ;
2203+ }
2204+
2205+ #[ test]
2206+ fn top_level_help_omits_header_when_disabled ( ) {
2207+ let help = command_with_help_with_options ( RenderOptions { show_header : false } )
2208+ . render_help ( )
2209+ . to_string ( ) ;
2210+
2211+ assert ! ( !help. starts_with( "VITE+ - The Unified Toolchain for the Web" ) ) ;
2212+ }
21872213}
0 commit comments