Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rossmacarthur committed Sep 3, 2020
1 parent 5726ba0 commit bc5f9d7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/cli.rs
Expand Up @@ -224,14 +224,23 @@ pub struct Opt {
}

impl LockMode {
fn from_lock_opts(update: bool, reinstall: bool) -> Self {
fn from_lock_flags(update: bool, reinstall: bool) -> Self {
match (update, reinstall) {
(false, false) => Self::Normal,
(true, false) => Self::Update,
(false, true) => Self::Reinstall,
(false, false) => Self::Normal,
(true, true) => unreachable!(),
}
}

fn from_source_flags(relock: bool, update: bool, reinstall: bool) -> (bool, Self) {
match (relock, update, reinstall) {
(relock, false, false) => (relock, Self::Normal),
(_, true, false) => (true, Self::Update),
(_, false, true) => (true, Self::Reinstall),
(_, true, true) => unreachable!(),
}
}
}

impl Plugin {
Expand Down Expand Up @@ -350,15 +359,15 @@ impl Opt {
RawCommand::Edit => Command::Edit,
RawCommand::Remove { name } => Command::Remove { name },
RawCommand::Lock { update, reinstall } => {
let mode = LockMode::from_lock_opts(update, reinstall);
let mode = LockMode::from_lock_flags(update, reinstall);
Command::Lock { mode }
}
RawCommand::Source {
relock,
update,
reinstall,
} => {
let mode = LockMode::from_lock_opts(update, reinstall);
let (relock, mode) = LockMode::from_source_flags(relock, update, reinstall);
Command::Source { relock, mode }
}
};
Expand Down

0 comments on commit bc5f9d7

Please sign in to comment.