uv_configuration/
dry_run.rs

1#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
2pub enum DryRun {
3    /// The operation should execute in dry run mode.
4    Enabled,
5    /// The operation should execute in dry run mode and check if the current environment is
6    /// synced.
7    Check,
8    /// The operation should execute in normal mode.
9    #[default]
10    Disabled,
11}
12
13impl DryRun {
14    /// Determine the [`DryRun`] setting based on the command-line arguments.
15    pub fn from_args(dry_run: bool) -> Self {
16        if dry_run {
17            Self::Enabled
18        } else {
19            Self::Disabled
20        }
21    }
22
23    /// Returns `true` if dry run mode is enabled.
24    pub const fn enabled(&self) -> bool {
25        matches!(self, Self::Enabled) || matches!(self, Self::Check)
26    }
27}