Skip to content

Commit e60358a

Browse files
committed
refactor: simplify vpr iterator construction with bool::then_some
1 parent e9ef42c commit e60358a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • packages/cli/binding/src

packages/cli/binding/src/cli.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,11 @@ impl CommandHandler for VitePlusCommandHandler {
558558
return Ok(HandledCommand::Verbatim);
559559
}
560560
// "vpr <args>" is shorthand for "vp run <args>", so prepend "run" for parsing.
561+
let is_vpr = program == "vpr";
561562
let cli_args = match CLIArgs::try_parse_from(
562-
iter::once("vp").chain(
563-
if program == "vpr" { Some("run") } else { None }
564-
.into_iter()
565-
.chain(command.args.iter().map(Str::as_str)),
566-
),
563+
iter::once("vp")
564+
.chain(is_vpr.then_some("run"))
565+
.chain(command.args.iter().map(Str::as_str)),
567566
) {
568567
Ok(args) => args,
569568
Err(err) if err.kind() == ErrorKind::InvalidSubcommand => {

0 commit comments

Comments
 (0)