Skip to content

Commit 9b689e9

Browse files
committed
refactor(cli): name the global-only subcommand list
Lift the inline env/upgrade/implode match into a documented constant that points at the global CLI command surface it mirrors.
1 parent 4d66c20 commit 9b689e9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/cli/binding/src/cli

packages/cli/binding/src/cli/help.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ use vt::ExitStatus;
66

77
use super::types::SynthesizableSubcommand;
88

9+
/// Subcommands that exist only in the global `vp` binary.
10+
///
11+
/// Keep in sync with the self-management variants of `Commands` in
12+
/// `crates/vp_global_cli/src/cli.rs`; the local CLI cannot run them and only
13+
/// needs the names to point users at the global installation.
14+
const GLOBAL_ONLY_SUBCOMMANDS: &[&str] = &["env", "upgrade", "implode"];
15+
916
pub(super) fn handle_cli_parse_error(err: clap::Error) -> Result<ExitStatus, Error> {
1017
if matches!(err.kind(), ErrorKind::InvalidSubcommand) && print_invalid_subcommand_error(&err) {
1118
return Ok(ExitStatus(err.exit_code() as u8));
@@ -119,7 +126,7 @@ fn print_invalid_subcommand_error(error: &clap::Error) -> bool {
119126
return false;
120127
};
121128

122-
if matches!(invalid_subcommand.as_str(), "env" | "upgrade" | "implode") {
129+
if GLOBAL_ONLY_SUBCOMMANDS.contains(&invalid_subcommand.as_str()) {
123130
let command = format!("`{invalid_subcommand}`").bright_blue().to_string();
124131
output::error(&format!(
125132
"The {command} command is only available in the global `vp` CLI. See https://viteplus.dev/guide/ to install it, then run the same command via the global `vp` binary."

0 commit comments

Comments
 (0)