Skip to content

Commit b0e91ab

Browse files
committed
Review
1 parent eed6a82 commit b0e91ab

File tree

7 files changed

+925
-797
lines changed

7 files changed

+925
-797
lines changed

crates/uv-cli/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,14 @@ pub enum PythonListFormat {
4646
Json,
4747
}
4848

49-
#[derive(Debug, Default, Clone, clap::ValueEnum)]
49+
#[derive(Debug, Default, Clone, Copy, clap::ValueEnum)]
5050
pub enum SyncFormat {
5151
/// Display the result in a human-readable format.
5252
#[default]
5353
Text,
5454
/// Display the result in JSON format.
5555
Json,
5656
}
57-
impl SyncFormat {
58-
pub fn is_json(&self) -> bool {
59-
matches!(self, SyncFormat::Json)
60-
}
61-
}
6257

6358
#[derive(Debug, Default, Clone, clap::ValueEnum)]
6459
pub enum ListFormat {
@@ -3179,7 +3174,7 @@ pub struct SyncArgs {
31793174

31803175
/// Select the output format.
31813176
#[arg(long, value_enum, default_value_t = SyncFormat::default())]
3182-
pub format: SyncFormat,
3177+
pub output_format: SyncFormat,
31833178

31843179
/// Include all optional dependencies.
31853180
///

crates/uv/src/commands/project/mod.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,14 +1212,14 @@ enum ProjectEnvironment {
12121212
/// requirements. A new environment would've been created, but `--dry-run` mode is enabled; as
12131213
/// such, a temporary environment was created instead.
12141214
WouldReplace(
1215-
#[allow(dead_code)] PathBuf,
1215+
PathBuf,
12161216
PythonEnvironment,
12171217
#[allow(unused)] tempfile::TempDir,
12181218
),
12191219
/// A new [`PythonEnvironment`] would've been created, but `--dry-run` mode is enabled; as such,
12201220
/// a temporary environment was created instead.
12211221
WouldCreate(
1222-
#[allow(dead_code)] PathBuf,
1222+
PathBuf,
12231223
PythonEnvironment,
12241224
#[allow(unused)] tempfile::TempDir,
12251225
),
@@ -1406,6 +1406,14 @@ impl ProjectEnvironment {
14061406
Self::WouldCreate(..) => Err(ProjectError::DroppedEnvironment),
14071407
}
14081408
}
1409+
1410+
/// Return the path to the actual target, if this was a dry run environment.
1411+
pub(crate) fn dry_run_target(&self) -> Option<&Path> {
1412+
match self {
1413+
Self::WouldReplace(path, _, _) | Self::WouldCreate(path, _, _) => Some(path),
1414+
Self::Created(_) | Self::Existing(_) | Self::Replaced(_) => None,
1415+
}
1416+
}
14091417
}
14101418

14111419
impl std::ops::Deref for ProjectEnvironment {
@@ -1436,14 +1444,14 @@ enum ScriptEnvironment {
14361444
/// requirements. A new environment would've been created, but `--dry-run` mode is enabled; as
14371445
/// such, a temporary environment was created instead.
14381446
WouldReplace(
1439-
#[allow(dead_code)] PathBuf,
1447+
PathBuf,
14401448
PythonEnvironment,
14411449
#[allow(unused)] tempfile::TempDir,
14421450
),
14431451
/// A new [`PythonEnvironment`] would've been created, but `--dry-run` mode is enabled; as such,
14441452
/// a temporary environment was created instead.
14451453
WouldCreate(
1446-
#[allow(dead_code)] PathBuf,
1454+
PathBuf,
14471455
PythonEnvironment,
14481456
#[allow(unused)] tempfile::TempDir,
14491457
),
@@ -1586,6 +1594,14 @@ impl ScriptEnvironment {
15861594
Self::WouldCreate(..) => Err(ProjectError::DroppedEnvironment),
15871595
}
15881596
}
1597+
1598+
/// Return the path to the actual target, if this was a dry run environment.
1599+
pub(crate) fn dry_run_target(&self) -> Option<&Path> {
1600+
match self {
1601+
Self::WouldReplace(path, _, _) | Self::WouldCreate(path, _, _) => Some(path),
1602+
Self::Created(_) | Self::Existing(_) | Self::Replaced(_) => None,
1603+
}
1604+
}
15891605
}
15901606

15911607
impl std::ops::Deref for ScriptEnvironment {

0 commit comments

Comments
 (0)