Add an option to always suspend vagrant boxes
This commit is contained in:
@@ -91,6 +91,7 @@ pub struct Git {
|
||||
pub struct Vagrant {
|
||||
directories: Option<Vec<String>>,
|
||||
power_on: Option<bool>,
|
||||
always_suspend: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
@@ -518,6 +519,14 @@ impl Config {
|
||||
.and_then(|vagrant| vagrant.directories.as_ref())
|
||||
}
|
||||
|
||||
/// Always suspend vagrant boxes instead of powering off
|
||||
pub fn vagrant_always_suspend(&self) -> Option<bool> {
|
||||
self.config_file
|
||||
.vagrant
|
||||
.as_ref()
|
||||
.and_then(|vagrant| vagrant.always_suspend)
|
||||
}
|
||||
|
||||
/// Extra yay arguments
|
||||
#[allow(dead_code)]
|
||||
pub fn enable_tlmgr_linux(&self) -> bool {
|
||||
|
||||
@@ -118,10 +118,14 @@ impl<'a> TemporaryPowerOn<'a> {
|
||||
|
||||
impl<'a> Drop for TemporaryPowerOn<'a> {
|
||||
fn drop(&mut self) {
|
||||
let subcommand = match self.status {
|
||||
BoxStatus::PowerOff | BoxStatus::Aborted => "halt",
|
||||
BoxStatus::Saved => "suspend",
|
||||
BoxStatus::Running => unreachable!(),
|
||||
let subcommand = if self.ctx.config().vagrant_always_suspend().unwrap_or(false) {
|
||||
"suspend"
|
||||
} else {
|
||||
match self.status {
|
||||
BoxStatus::PowerOff | BoxStatus::Aborted => "halt",
|
||||
BoxStatus::Saved => "suspend",
|
||||
BoxStatus::Running => unreachable!(),
|
||||
}
|
||||
};
|
||||
|
||||
println!("Powering off {}", self.vagrant_box);
|
||||
|
||||
Reference in New Issue
Block a user