feat: add damp run type (#1217)

Co-authored-by: Stuart Reilly <sreilly@scottlogic.com>
This commit is contained in:
Stuart Reilly
2025-11-02 14:06:35 +00:00
committed by GitHub
parent 8fc25d7fd4
commit 99892359c7
12 changed files with 164 additions and 109 deletions

View File

@@ -38,7 +38,7 @@ pub fn run_mas(ctx: &ExecutionContext) -> Result<()> {
pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> {
print_separator(t!("macOS system update"));
let should_ask = !(ctx.config().yes(Step::System) || ctx.config().dry_run());
let should_ask = !(ctx.config().yes(Step::System) || ctx.run_type().dry());
if should_ask {
println!("{}", t!("Finding available software"));
if system_update_available()? {
@@ -95,7 +95,7 @@ pub fn update_xcodes(ctx: &ExecutionContext) -> Result<()> {
let xcodes = require("xcodes")?;
print_separator("Xcodes");
let should_ask = !(ctx.config().yes(Step::Xcodes) || ctx.config().dry_run());
let should_ask = !(ctx.config().yes(Step::Xcodes) || ctx.run_type().dry());
let releases = ctx.execute(&xcodes).args(["update"]).output_checked_utf8()?.stdout;

View File

@@ -1,5 +1,6 @@
use crate::command::CommandExt;
use crate::execution_context::ExecutionContext;
use crate::executor::RunType;
use crate::terminal::print_separator;
use color_eyre::eyre::Result;
use rust_i18n::t;
@@ -8,12 +9,13 @@ use std::fs;
fn is_openbsd_current(ctx: &ExecutionContext) -> Result<bool> {
let motd_content = fs::read_to_string("/etc/motd")?;
let is_current = ["-current", "-beta"].iter().any(|&s| motd_content.contains(s));
if ctx.config().dry_run() {
println!("{}", t!("Would check if OpenBSD is -current"));
Ok(is_current)
} else {
Ok(is_current)
match ctx.config.run_type() {
RunType::Dry | RunType::Damp => {
println!("{}", t!("Checking if /etc/motd contains -current or -beta"));
}
RunType::Wet => {}
}
Ok(is_current)
}
pub fn upgrade_openbsd(ctx: &ExecutionContext) -> Result<()> {
@@ -42,11 +44,6 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
let is_current = is_openbsd_current(ctx)?;
if ctx.config().dry_run() {
println!("{}", t!("Would upgrade OpenBSD packages"));
return Ok(());
}
if ctx.config().cleanup() {
sudo.execute(ctx, "/usr/sbin/pkg_delete")?.arg("-ac").status_checked()?;
}