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