Skip to content

Commit fb93f6f

Browse files
branchseerclaude
andauthored
feat: restrict interactive task selector to bare vp run and cwd-only (#183)
## Summary - The interactive task selector now only appears for bare `vp run` or simple `vp run <taskname>` (cwd-only). Running with scope flags like `-r`, `-t`, `-w`, or `--filter` will show an error instead of the selector when the task is not found. - After selecting a task from the interactive selector, prints **Selected task:** followed by the task name before executing. - Error messages now include the task name: `Task "buid" not found` instead of the generic `no tasks matched the query`. - `vp run --verbose` (or any non-scope flag without a task) correctly errors with "No task specifier provided" instead of showing the selector. - `vp run buid --verbose` still enters the selector since `--verbose` is not a scope flag — only package-scope flags (`-r`, `-t`, `-w`, `--filter`) gate the selector. ## Test plan - [x] `cargo test -p vite_task_bin --test e2e_snapshots -- task-select` — all pass - [x] `cargo test` — all pass - [x] `just lint` — clean --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3a6f3d8 commit fb93f6f

26 files changed

+244
-171
lines changed

crates/vite_task/src/cli/mod.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum CacheSubcommand {
1414
}
1515

1616
/// Flags that control how a `run` command selects tasks.
17-
#[derive(Debug, Clone, clap::Args)]
17+
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
1818
pub struct RunFlags {
1919
#[clap(flatten)]
2020
pub package_query: PackageQueryArgs,
@@ -36,10 +36,10 @@ pub struct RunFlags {
3636
///
3737
/// Contains the `--last-details` flag which is resolved into a separate
3838
/// `ResolvedCommand::RunLastDetails` variant internally.
39-
#[derive(Debug, clap::Args)]
39+
#[derive(Debug, clap::Parser)]
4040
pub struct RunCommand {
4141
/// `packageName#taskName` or `taskName`. If omitted, lists all available tasks.
42-
pub(crate) task_specifier: Option<TaskSpecifier>,
42+
pub(crate) task_specifier: Option<Str>,
4343

4444
#[clap(flatten)]
4545
pub(crate) flags: RunFlags,
@@ -109,10 +109,10 @@ pub enum ResolvedCommand {
109109
///
110110
/// Does not contain `last_details` — that case is represented by
111111
/// [`ResolvedCommand::RunLastDetails`] instead.
112-
#[derive(Debug)]
112+
#[derive(Debug, Clone, PartialEq, Eq)]
113113
pub struct ResolvedRunCommand {
114114
/// `packageName#taskName` or `taskName`. If omitted, lists all available tasks.
115-
pub task_specifier: Option<TaskSpecifier>,
115+
pub task_specifier: Option<Str>,
116116

117117
pub flags: RunFlags,
118118

@@ -151,21 +151,25 @@ impl ResolvedRunCommand {
151151
pub fn into_query_plan_request(
152152
self,
153153
cwd: &Arc<AbsolutePath>,
154-
) -> Result<QueryPlanRequest, CLITaskQueryError> {
155-
let task_specifier = self.task_specifier.ok_or(CLITaskQueryError::MissingTaskSpecifier)?;
154+
) -> Result<(QueryPlanRequest, bool), CLITaskQueryError> {
155+
let raw_specifier = self.task_specifier.ok_or(CLITaskQueryError::MissingTaskSpecifier)?;
156+
let task_specifier = TaskSpecifier::parse_raw(&raw_specifier);
156157

157-
let (package_query, _is_cwd_only) =
158+
let (package_query, is_cwd_only) =
158159
self.flags.package_query.into_package_query(task_specifier.package_name, cwd)?;
159160

160161
let include_explicit_deps = !self.flags.ignore_depends_on;
161162

162-
Ok(QueryPlanRequest {
163-
query: TaskQuery {
164-
package_query,
165-
task_name: task_specifier.task_name,
166-
include_explicit_deps,
163+
Ok((
164+
QueryPlanRequest {
165+
query: TaskQuery {
166+
package_query,
167+
task_name: task_specifier.task_name,
168+
include_explicit_deps,
169+
},
170+
plan_options: PlanOptions { extra_args: self.additional_args.into() },
167171
},
168-
plan_options: PlanOptions { extra_args: self.additional_args.into() },
169-
})
172+
is_cwd_only,
173+
))
170174
}
171175
}

0 commit comments

Comments
 (0)