@@ -2118,12 +2118,12 @@ pub fn command_with_help_with_options(render_options: RenderOptions) -> clap::Co
21182118/// Apply custom help formatting to a clap Command to match the JS CLI output.
21192119fn apply_custom_help ( cmd : clap:: Command , render_options : RenderOptions ) -> clap:: Command {
21202120 let after_help = help:: render_help_doc ( & help:: top_level_help_doc ( ) ) ;
2121- let options_heading = help:: render_heading ( "Options" ) ;
21222121 let header = if render_options. show_header && vite_shared:: header:: should_print_header ( ) {
2123- vite_shared:: header:: vite_plus_header ( )
2122+ format ! ( "{} \n \n " , vite_shared:: header:: vite_plus_header( ) )
21242123 } else {
21252124 String :: new ( )
21262125 } ;
2126+ let options_heading = help:: render_heading ( "Options" ) ;
21272127 let help_template = format ! ( "{header}{{after-help}}\n {options_heading}\n {{options}}\n " ) ;
21282128
21292129 cmd. after_help ( after_help) . help_template ( help_template)
@@ -2150,7 +2150,10 @@ pub fn try_parse_args_from_with_options(
21502150
21512151#[ cfg( test) ]
21522152mod tests {
2153- use super :: { has_flag_before_terminator, should_force_global_delegate} ;
2153+ use super :: {
2154+ RenderOptions , command_with_help_with_options, has_flag_before_terminator,
2155+ should_force_global_delegate,
2156+ } ;
21542157
21552158 #[ test]
21562159 fn detects_flag_before_option_terminator ( ) {
@@ -2183,4 +2186,22 @@ mod tests {
21832186 assert ! ( !should_force_global_delegate( "lint" , & [ "src/index.ts" . to_string( ) ] ) ) ;
21842187 assert ! ( !should_force_global_delegate( "fmt" , & [ "--check" . to_string( ) ] ) ) ;
21852188 }
2189+
2190+ #[ test]
2191+ fn top_level_help_includes_header_when_enabled ( ) {
2192+ let help = command_with_help_with_options ( RenderOptions { show_header : true } )
2193+ . render_help ( )
2194+ . to_string ( ) ;
2195+
2196+ assert ! ( help. starts_with( "VITE+ - The Unified Toolchain for the Web\n \n " ) ) ;
2197+ }
2198+
2199+ #[ test]
2200+ fn top_level_help_omits_header_when_disabled ( ) {
2201+ let help = command_with_help_with_options ( RenderOptions { show_header : false } )
2202+ . render_help ( )
2203+ . to_string ( ) ;
2204+
2205+ assert ! ( !help. starts_with( "VITE+ - The Unified Toolchain for the Web" ) ) ;
2206+ }
21862207}
0 commit comments