zoi/cmd/
rollback.rs

1use crate::pkg::{self, transaction};
2use crate::utils;
3use anyhow::Result;
4
5pub fn run(package_name: &str, yes: bool) -> Result<()> {
6    pkg::rollback::run(package_name, yes)
7}
8
9pub fn run_transaction_rollback(yes: bool) -> Result<()> {
10    if !utils::ask_for_confirmation(
11        "This will roll back the last recorded transaction. Are you sure?",
12        yes,
13    ) {
14        println!("Operation aborted.");
15        return Ok(());
16    }
17
18    match transaction::get_last_transaction_id()? {
19        Some(id) => {
20            println!("Rolling back transaction {}...", id);
21            transaction::rollback(&id)
22        }
23        None => {
24            println!("No transactions found to roll back.");
25            Ok(())
26        }
27    }
28}