Skip to content

Commit e222498

Browse files
committed
chore(cli): drop header workaround changes
1 parent 9d7a6ae commit e222498

2 files changed

Lines changed: 16 additions & 38 deletions

File tree

crates/vite_global_cli/src/cli.rs

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ pub async fn run_command_with_options(
16461646
packages,
16471647
pass_through_args,
16481648
} => {
1649-
print_runtime_header(render_options.show_header && !silent, true);
1649+
print_runtime_header(render_options.show_header && !silent);
16501650
// If packages are provided, redirect to Add command
16511651
if let Some(pkgs) = packages
16521652
&& !pkgs.is_empty()
@@ -1972,31 +1972,31 @@ pub async fn run_command_with_options(
19721972
if help::maybe_print_unified_delegate_help("dev", &args, render_options.show_header) {
19731973
return Ok(ExitStatus::default());
19741974
}
1975-
print_runtime_header(render_options.show_header, false);
1975+
print_runtime_header(render_options.show_header);
19761976
commands::delegate::execute(cwd, "dev", &args).await
19771977
}
19781978

19791979
Commands::Build { args } => {
19801980
if help::maybe_print_unified_delegate_help("build", &args, render_options.show_header) {
19811981
return Ok(ExitStatus::default());
19821982
}
1983-
print_runtime_header(render_options.show_header, false);
1983+
print_runtime_header(render_options.show_header);
19841984
commands::delegate::execute(cwd, "build", &args).await
19851985
}
19861986

19871987
Commands::Test { args } => {
19881988
if help::maybe_print_unified_delegate_help("test", &args, render_options.show_header) {
19891989
return Ok(ExitStatus::default());
19901990
}
1991-
print_runtime_header(render_options.show_header, false);
1991+
print_runtime_header(render_options.show_header);
19921992
commands::delegate::execute(cwd, "test", &args).await
19931993
}
19941994

19951995
Commands::Lint { args } => {
19961996
if help::maybe_print_unified_delegate_help("lint", &args, render_options.show_header) {
19971997
return Ok(ExitStatus::default());
19981998
}
1999-
print_runtime_header(render_options.show_header, false);
1999+
print_runtime_header(render_options.show_header);
20002000
if should_force_global_delegate("lint", &args) {
20012001
commands::delegate::execute_global(cwd, "lint", &args).await
20022002
} else {
@@ -2008,7 +2008,7 @@ pub async fn run_command_with_options(
20082008
if help::maybe_print_unified_delegate_help("fmt", &args, render_options.show_header) {
20092009
return Ok(ExitStatus::default());
20102010
}
2011-
print_runtime_header(render_options.show_header, false);
2011+
print_runtime_header(render_options.show_header);
20122012
if should_force_global_delegate("fmt", &args) {
20132013
commands::delegate::execute_global(cwd, "fmt", &args).await
20142014
} else {
@@ -2020,31 +2020,31 @@ pub async fn run_command_with_options(
20202020
if help::maybe_print_unified_delegate_help("check", &args, render_options.show_header) {
20212021
return Ok(ExitStatus::default());
20222022
}
2023-
print_runtime_header(render_options.show_header, false);
2023+
print_runtime_header(render_options.show_header);
20242024
commands::delegate::execute(cwd, "check", &args).await
20252025
}
20262026

20272027
Commands::Pack { args } => {
20282028
if help::maybe_print_unified_delegate_help("pack", &args, render_options.show_header) {
20292029
return Ok(ExitStatus::default());
20302030
}
2031-
print_runtime_header(render_options.show_header, false);
2031+
print_runtime_header(render_options.show_header);
20322032
commands::delegate::execute(cwd, "pack", &args).await
20332033
}
20342034

20352035
Commands::Run { args } => {
20362036
if help::maybe_print_unified_delegate_help("run", &args, render_options.show_header) {
20372037
return Ok(ExitStatus::default());
20382038
}
2039-
print_runtime_header(render_options.show_header, false);
2039+
print_runtime_header(render_options.show_header);
20402040
commands::delegate::execute(cwd, "run", &args).await
20412041
}
20422042

20432043
Commands::Exec { args } => {
20442044
if help::maybe_print_unified_delegate_help("exec", &args, render_options.show_header) {
20452045
return Ok(ExitStatus::default());
20462046
}
2047-
print_runtime_header(render_options.show_header, false);
2047+
print_runtime_header(render_options.show_header);
20482048
commands::delegate::execute(cwd, "exec", &args).await
20492049
}
20502050

@@ -2053,15 +2053,15 @@ pub async fn run_command_with_options(
20532053
{
20542054
return Ok(ExitStatus::default());
20552055
}
2056-
print_runtime_header(render_options.show_header, false);
2056+
print_runtime_header(render_options.show_header);
20572057
commands::delegate::execute(cwd, "preview", &args).await
20582058
}
20592059

20602060
Commands::Cache { args } => {
20612061
if help::maybe_print_unified_delegate_help("cache", &args, render_options.show_header) {
20622062
return Ok(ExitStatus::default());
20632063
}
2064-
print_runtime_header(render_options.show_header, false);
2064+
print_runtime_header(render_options.show_header);
20652065
commands::delegate::execute(cwd, "cache", &args).await
20662066
}
20672067

@@ -2098,7 +2098,7 @@ pub(crate) fn exit_status(code: i32) -> ExitStatus {
20982098
}
20992099
}
21002100

2101-
fn print_runtime_header(show_header: bool, _dynamic_colors: bool) {
2101+
fn print_runtime_header(show_header: bool) {
21022102
if !show_header {
21032103
return;
21042104
}
@@ -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.
21192119
fn 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");
21212122
let header = if render_options.show_header && vite_shared::header::should_print_header() {
21222123
format!("{}\n\n", vite_shared::header::vite_plus_header())
21232124
} else {
21242125
String::new()
21252126
};
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,10 +2150,7 @@ pub fn try_parse_args_from_with_options(
21502150

21512151
#[cfg(test)]
21522152
mod tests {
2153-
use super::{
2154-
RenderOptions, command_with_help_with_options, has_flag_before_terminator,
2155-
should_force_global_delegate,
2156-
};
2153+
use super::{has_flag_before_terminator, should_force_global_delegate};
21572154

21582155
#[test]
21592156
fn detects_flag_before_option_terminator() {
@@ -2186,22 +2183,4 @@ mod tests {
21862183
assert!(!should_force_global_delegate("lint", &["src/index.ts".to_string()]));
21872184
assert!(!should_force_global_delegate("fmt", &["--check".to_string()]));
21882185
}
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-
}
22072186
}

crates/vite_global_cli/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ async fn main() -> ExitCode {
320320
}
321321

322322
// Parse CLI arguments (using custom help formatting)
323-
let parse_result =
324-
try_parse_args_from_with_options(normalized_args, RenderOptions { show_header: false });
323+
let parse_result = try_parse_args_from(normalized_args);
325324

326325
// Spawn background upgrade check for eligible commands
327326
let upgrade_handle = match &parse_result {

0 commit comments

Comments
 (0)