Skip to content

Commit 22978f1

Browse files
committed
chore(cli): drop header workaround changes
1 parent 3ee3a11 commit 22978f1

File tree

2 files changed

+18
-48
lines changed

2 files changed

+18
-48
lines changed

crates/vite_global_cli/src/cli.rs

Lines changed: 17 additions & 43 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,16 +2098,11 @@ 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
}
2105-
let header = if dynamic_colors {
2106-
vite_shared::header::vite_plus_header()
2107-
} else {
2108-
vite_shared::header::vite_plus_header_static()
2109-
};
2110-
println!("{header}");
2105+
println!("{}", vite_shared::header::vite_plus_header());
21112106
println!();
21122107
}
21132108

@@ -2124,12 +2119,12 @@ pub fn command_with_help_with_options(render_options: RenderOptions) -> clap::Co
21242119
/// Apply custom help formatting to a clap Command to match the JS CLI output.
21252120
fn apply_custom_help(cmd: clap::Command, render_options: RenderOptions) -> clap::Command {
21262121
let after_help = help::render_help_doc(&help::top_level_help_doc());
2122+
let options_heading = help::render_heading("Options");
21272123
let header = if render_options.show_header {
2128-
format!("{}\n\n", vite_shared::header::vite_plus_header())
2124+
vite_shared::header::vite_plus_header()
21292125
} else {
21302126
String::new()
21312127
};
2132-
let options_heading = help::render_heading("Options");
21332128
let help_template = format!("{header}{{after-help}}\n{options_heading}\n{{options}}\n");
21342129

21352130
cmd.after_help(after_help).help_template(help_template)
@@ -2156,10 +2151,7 @@ pub fn try_parse_args_from_with_options(
21562151

21572152
#[cfg(test)]
21582153
mod tests {
2159-
use super::{
2160-
RenderOptions, command_with_help_with_options, has_flag_before_terminator,
2161-
should_force_global_delegate,
2162-
};
2154+
use super::{has_flag_before_terminator, should_force_global_delegate};
21632155

21642156
#[test]
21652157
fn detects_flag_before_option_terminator() {
@@ -2192,22 +2184,4 @@ mod tests {
21922184
assert!(!should_force_global_delegate("lint", &["src/index.ts".to_string()]));
21932185
assert!(!should_force_global_delegate("fmt", &["--check".to_string()]));
21942186
}
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-
}
22132187
}

crates/vite_global_cli/src/main.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ async fn main() -> ExitCode {
322322
}
323323

324324
// Parse CLI arguments (using custom help formatting)
325-
let parse_result =
326-
try_parse_args_from_with_options(normalized_args, RenderOptions { show_header: false });
325+
let parse_result = try_parse_args_from(normalized_args);
327326

328327
// Spawn background upgrade check for eligible commands
329328
let upgrade_handle = match &parse_result {
@@ -339,9 +338,6 @@ async fn main() -> ExitCode {
339338

340339
// --help and --version are clap "errors" but should exit successfully.
341340
if matches!(e.kind(), ErrorKind::DisplayHelp | ErrorKind::DisplayVersion) {
342-
if e.kind() == ErrorKind::DisplayHelp {
343-
println!("{}", vite_shared::header::vite_plus_header());
344-
}
345341
e.print().ok();
346342
ExitCode::SUCCESS
347343
} else if matches!(e.kind(), ErrorKind::InvalidSubcommand) {

0 commit comments

Comments
 (0)