Skip to content

Commit 264a499

Browse files
authored
feat(cli): enable vpx tip (#675)
## Summary - Enable the `UseVpxOrRun` tip that was disabled with a TODO pending `vpx` support - Uncomment the tip logic and its tests in `use_vpx_or_run.rs` - Remove `#[expect(dead_code)]` from `is_unknown_command_error()` since it's now used When users run an unknown command (e.g. `vp typecheck`), they'll now see a tip suggesting `vpx <bin>` or `vp run <script>`. ## Test plan - [ ] CI passes `cargo test -p vite_global_cli` with the newly enabled tests 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 1a17ccd commit 264a499

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

crates/vite_global_cli/src/tips/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ impl TipContext {
3333
self.exit_code == 0
3434
}
3535

36-
#[expect(dead_code)]
3736
pub fn is_unknown_command_error(&self) -> bool {
3837
if let Some(err) = &self.clap_error {
3938
matches!(err.kind(), ClapErrorKind::InvalidSubcommand)

crates/vite_global_cli/src/tips/use_vpx_or_run.rs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,35 @@
22
33
use super::{Tip, TipContext};
44

5-
/// Suggest `vpx <bin>` or `vp run <script>` when an unknown command is used.
5+
/// Suggest `vpx <pkg>` or `vp run <script>` when an unknown command is used.
66
pub struct UseVpxOrRun;
77

88
impl Tip for UseVpxOrRun {
9-
fn matches(&self, _ctx: &TipContext) -> bool {
10-
// TODO: Enable when `vpx` is supported
11-
// ctx.is_unknown_command_error()
12-
false
9+
fn matches(&self, ctx: &TipContext) -> bool {
10+
ctx.is_unknown_command_error()
1311
}
1412

1513
fn message(&self) -> &'static str {
16-
"Run a local binary with `vpx <bin>`, or a script with `vp run <script>`"
14+
"Execute a package binary with `vpx <pkg[@version]>`, or a script with `vp run <script>`"
1715
}
1816
}
1917

20-
// TODO: Re-enable tests when `vpx` is supported
21-
// #[cfg(test)]
22-
// mod tests {
23-
// use super::*;
24-
// use crate::tips::tip_context_from_command;
25-
//
26-
// #[test]
27-
// fn matches_on_unknown_command() {
28-
// let ctx = tip_context_from_command("vp typecheck");
29-
// assert!(UseVpxOrRun.matches(&ctx));
30-
// assert!(ctx.is_unknown_command_error());
31-
// }
32-
//
33-
// #[test]
34-
// fn does_not_match_on_known_command() {
35-
// let ctx = tip_context_from_command("vp build");
36-
// assert!(!UseVpxOrRun.matches(&ctx));
37-
// assert!(!ctx.is_unknown_command_error());
38-
// }
39-
// }
18+
#[cfg(test)]
19+
mod tests {
20+
use super::*;
21+
use crate::tips::tip_context_from_command;
22+
23+
#[test]
24+
fn matches_on_unknown_command() {
25+
let ctx = tip_context_from_command("vp typecheck");
26+
assert!(UseVpxOrRun.matches(&ctx));
27+
assert!(ctx.is_unknown_command_error());
28+
}
29+
30+
#[test]
31+
fn does_not_match_on_known_command() {
32+
let ctx = tip_context_from_command("vp build");
33+
assert!(!UseVpxOrRun.matches(&ctx));
34+
assert!(!ctx.is_unknown_command_error());
35+
}
36+
}

0 commit comments

Comments
 (0)