From 9f9ee397c787ebe58e7304bd75fedf7ed4993eaa Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Mar 2026 16:14:28 +0000 Subject: [PATCH 1/2] fix: use value_names for better help text in RunCommand Use `value_names = ["TASK_SPECIFIER", "ADDITIONAL_ARGS"]` so the help output shows `[TASK_SPECIFIER] [ADDITIONAL_ARGS]...` instead of the generic `[TASK_AND_ARGS]...`. https://claude.ai/code/session_018viAL2UGVNfLuUjTsi44HQ --- crates/vite_task/src/cli/mod.rs | 28 ++++++++++++------- ...ery - --cache and --no-cache conflict.snap | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index dd4605e7..15998252 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -74,7 +74,16 @@ impl RunFlags { /// /// Contains the `--last-details` flag which is resolved into a separate /// `ResolvedCommand::RunLastDetails` variant internally. +/// +/// `trailing_var_arg` at the command level makes clap stop matching flags once +/// the trailing positional starts being filled. This means all tokens after the +/// task name are passed through to the task verbatim, preventing flags like `-v` +/// from being intercepted. Flags intended for `vp` itself (e.g. `--verbose`, +/// `-r`) must appear **before** the task name. +/// +/// See . #[derive(Debug, clap::Parser)] +#[command(trailing_var_arg = true)] pub struct RunCommand { #[clap(flatten)] pub(crate) flags: RunFlags, @@ -83,11 +92,9 @@ pub struct RunCommand { #[clap(long, exclusive = true)] pub(crate) last_details: bool, - /// The task name and all arguments to pass to the task process - /// Prevent flags after the task name to be consumed by Vite Task with `trailing_var_arg` - /// - /// - #[clap(trailing_var_arg = true, allow_hyphen_values = true)] + /// `packageName#taskName` or `taskName`, followed by any additional + /// arguments to pass to the task. + #[clap(allow_hyphen_values = true, value_names = ["TASK_SPECIFIER", "ADDITIONAL_ARGS"])] pub(crate) task_and_args: Vec, } @@ -160,14 +167,15 @@ pub struct ResolvedRunCommand { impl RunCommand { /// Convert to the resolved run command, stripping the `last_details` flag. + /// + /// Splits `task_and_args` into `task_specifier` (the first element) and + /// `additional_args` (everything that follows). #[must_use] pub(crate) fn into_resolved(self) -> ResolvedRunCommand { let mut iter = self.task_and_args.into_iter(); - ResolvedRunCommand { - task_specifier: iter.next(), - flags: self.flags, - additional_args: iter.collect(), - } + let task_specifier = iter.next(); + let additional_args: Vec = iter.collect(); + ResolvedRunCommand { task_specifier, flags: self.flags, additional_args } } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap index f2467331..2d3ca9d8 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap @@ -11,6 +11,6 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-overri --- error: the argument '--cache' cannot be used with '--no-cache' -Usage: vt run --cache ... +Usage: vt run --cache ... For more information, try '--help'. From 30f7fa5a1e6f61d2de1a4582b7b16f9094d480f1 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Mar 2026 16:20:29 +0000 Subject: [PATCH 2/2] fix: mention interactive task selector in help text Note that omitting the task specifier in an interactive terminal opens an interactive task selector. https://claude.ai/code/session_018viAL2UGVNfLuUjTsi44HQ --- crates/vite_task/src/cli/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index 15998252..65cf6122 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -92,9 +92,11 @@ pub struct RunCommand { #[clap(long, exclusive = true)] pub(crate) last_details: bool, - /// `packageName#taskName` or `taskName`, followed by any additional - /// arguments to pass to the task. - #[clap(allow_hyphen_values = true, value_names = ["TASK_SPECIFIER", "ADDITIONAL_ARGS"])] + #[clap( + allow_hyphen_values = true, + value_names = ["TASK_SPECIFIER", "ADDITIONAL_ARGS"], + long_help = "Task to run, as `packageName#taskName` or just `taskName`.\nAny arguments after the task name are forwarded to the task process.\nRunning `vp run` without a task name shows an interactive task selector." + )] pub(crate) task_and_args: Vec, }