Skip to content

Commit bc5f9d7

Browse files
committed
Fix --relock not being implied for other flags
This fixes a bug where passing `--update` or `--reinstall` to the `source` command didn't imply `--relock` like the documentation says.
1 parent 5726ba0 commit bc5f9d7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/cli.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,23 @@ pub struct Opt {
224224
}
225225

226226
impl LockMode {
227-
fn from_lock_opts(update: bool, reinstall: bool) -> Self {
227+
fn from_lock_flags(update: bool, reinstall: bool) -> Self {
228228
match (update, reinstall) {
229+
(false, false) => Self::Normal,
229230
(true, false) => Self::Update,
230231
(false, true) => Self::Reinstall,
231-
(false, false) => Self::Normal,
232232
(true, true) => unreachable!(),
233233
}
234234
}
235+
236+
fn from_source_flags(relock: bool, update: bool, reinstall: bool) -> (bool, Self) {
237+
match (relock, update, reinstall) {
238+
(relock, false, false) => (relock, Self::Normal),
239+
(_, true, false) => (true, Self::Update),
240+
(_, false, true) => (true, Self::Reinstall),
241+
(_, true, true) => unreachable!(),
242+
}
243+
}
235244
}
236245

237246
impl Plugin {
@@ -350,15 +359,15 @@ impl Opt {
350359
RawCommand::Edit => Command::Edit,
351360
RawCommand::Remove { name } => Command::Remove { name },
352361
RawCommand::Lock { update, reinstall } => {
353-
let mode = LockMode::from_lock_opts(update, reinstall);
362+
let mode = LockMode::from_lock_flags(update, reinstall);
354363
Command::Lock { mode }
355364
}
356365
RawCommand::Source {
357366
relock,
358367
update,
359368
reinstall,
360369
} => {
361-
let mode = LockMode::from_lock_opts(update, reinstall);
370+
let (relock, mode) = LockMode::from_source_flags(relock, update, reinstall);
362371
Command::Source { relock, mode }
363372
}
364373
};

0 commit comments

Comments
 (0)