Skip to content

Commit

Permalink
Address review comments: Optional RunCommand
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
  • Loading branch information
kakkoyun committed Sep 26, 2024
1 parent f9a62eb commit 86892f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use crate::settings::ResolverInstallerSettings;
pub(crate) async fn run(
project_dir: &Path,
script: Option<Pep723Script>,
command: RunCommand,
command: Option<RunCommand>,
requirements: Vec<RequirementsSource>,
show_resolution: bool,
locked: bool,
Expand Down Expand Up @@ -721,7 +721,7 @@ pub(crate) async fn run(

// Check if any run command is given.
// If not, print the available scripts for the current interpreter.
if let RunCommand::Empty = command {
let Some(command) = command else {
writeln!(
printer.stdout(),
"Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.\n"
Expand Down
14 changes: 6 additions & 8 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ async fn run(cli: Cli) -> Result<ExitStatus> {

// Parse the external command, if necessary.
let run_command = if let Commands::Project(command) = &*cli.command {
if let ProjectCommand::Run(uv_cli::RunArgs { command, .. }) = &**command {
match command {
Some(command) => Some(RunCommand::try_from(command)?),
None => Some(RunCommand::Empty),
}
if let ProjectCommand::Run(uv_cli::RunArgs {
command: Some(command),
..
}) = &**command
{
Some(RunCommand::try_from(command)?)
} else {
None
}
Expand Down Expand Up @@ -1230,9 +1231,6 @@ async fn run_project(
)
.collect::<Vec<_>>();

// Given `ProjectCommand::Run`, we always expect a `RunCommand` to be present.
let command = command.expect("run command is required");

Box::pin(commands::run(
project_dir,
script,
Expand Down

0 comments on commit 86892f6

Please sign in to comment.