Skip to content

Commit d6ec191

Browse files
committed
refactor: rename BuiltInCommand to Command and update references
1 parent 72c426f commit d6ec191

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

crates/vite_task/src/cli/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::sync::Arc;
22

3-
use clap::Subcommand;
3+
use clap::Parser;
44
use vite_path::AbsolutePath;
55
use vite_str::Str;
66
use vite_task_graph::{TaskSpecifier, query::TaskQueryKind};
77
use vite_task_plan::plan_request::{PlanOptions, PlanRequest, QueryPlanRequest};
88

99
/// vite task CLI subcommands
10-
#[derive(Debug, Subcommand)]
11-
pub enum BuiltInCommand {
10+
#[derive(Debug, Parser)]
11+
pub enum Command {
1212
/// Run tasks
1313
Run {
1414
/// `packageName#taskName` or `taskName`.
@@ -41,7 +41,7 @@ pub enum CLITaskQueryError {
4141
PackageNameSpecifiedWithRecursive { package_name: Str, task_name: Str },
4242
}
4343

44-
impl BuiltInCommand {
44+
impl Command {
4545
/// Convert to `PlanRequest`, or return an error if invalid.
4646
pub fn into_plan_request(
4747
self,

crates/vite_task/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod maybe_str;
44
pub mod session;
55

66
// Public exports for vite_task_bin
7-
pub use cli::BuiltInCommand;
7+
pub use cli::Command;
88
pub use session::{LabeledReporter, Reporter, Session, SessionCallbacks, TaskSynthesizer};
99
pub use vite_task_graph::{
1010
config::{

crates/vite_task/src/session/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use vite_task_plan::{
2222
};
2323
use vite_workspace::{WorkspaceRoot, find_workspace_root};
2424

25-
use crate::{cli::BuiltInCommand, collections::HashMap};
25+
use crate::{cli::Command, collections::HashMap};
2626

2727
#[derive(Debug)]
2828
enum LazyTaskGraph<'a> {
@@ -100,14 +100,9 @@ impl vite_task_plan::PlanRequestParser for PlanRequestParser<'_> {
100100
}
101101

102102
// Try built-in "run" command (handles "vite run build" in scripts)
103-
#[derive(Parser)]
104-
enum BuiltInParser {
105-
#[clap(flatten)]
106-
Command(BuiltInCommand),
107-
}
108-
if let Ok(BuiltInParser::Command(built_in)) = BuiltInParser::try_parse_from(
109-
std::iter::once(program).chain(args.iter().map(Str::as_str)),
110-
) {
103+
if let Ok(built_in) =
104+
Command::try_parse_from(std::iter::once(program).chain(args.iter().map(Str::as_str)))
105+
{
111106
return Ok(Some(built_in.into_plan_request(cwd)?));
112107
}
113108

@@ -223,7 +218,7 @@ impl<'a> Session<'a> {
223218
pub async fn plan_from_cli(
224219
&mut self,
225220
cwd: Arc<AbsolutePath>,
226-
command: BuiltInCommand,
221+
command: Command,
227222
) -> Result<ExecutionPlan, vite_task_plan::Error> {
228223
let plan_request = command.into_plan_request(&cwd).map_err(|error| {
229224
TaskPlanErrorKind::ParsePlanRequestError {

crates/vite_task_bin/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{process::ExitCode, sync::Arc};
33
use clap::Parser;
44
use vite_path::{AbsolutePath, current_dir};
55
use vite_task::{
6-
BuiltInCommand, Session,
6+
Command, Session,
77
session::reporter::{ExitStatus, LabeledReporter},
88
};
99
use vite_task_bin::OwnedSessionCallbacks;
@@ -12,7 +12,7 @@ use vite_task_bin::OwnedSessionCallbacks;
1212
#[command(name = "vite", version)]
1313
struct Cli {
1414
#[command(subcommand)]
15-
command: BuiltInCommand,
15+
command: Command,
1616
}
1717

1818
#[tokio::main]

crates/vite_task_plan/tests/plan_snapshots/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ use redact::redact_snapshot;
88
use tokio::runtime::Runtime;
99
use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf};
1010
use vite_str::Str;
11-
use vite_task::{BuiltInCommand, Session};
11+
use vite_task::{Command, Session};
1212
use vite_workspace::find_workspace_root;
1313

1414
/// Local parser wrapper for BuiltInCommand
1515
#[derive(Parser)]
1616
#[command(name = "vite")]
1717
enum Cli {
1818
#[clap(flatten)]
19-
Command(BuiltInCommand),
19+
Command(Command),
2020
}
2121

2222
#[derive(serde::Deserialize, Debug)]

0 commit comments

Comments
 (0)