Skip to main content

close_unit

Function close_unit 

Source
pub fn close_unit(
    mana_dir: &Path,
    id: &str,
    opts: CloseOpts,
) -> Result<CloseOutcome, Error>
Expand description

Close a unit — run verify, archive, and cascade to parents.

The full close lifecycle:

  1. Pre-close hook (if configured)
  2. Run verify command (unless opts.force is true)
  3. Worktree merge (if in worktree mode)
  4. Feature gate (feature units require manual confirmation)
  5. Mark closed and archive
  6. Post-close hook and on_close actions
  7. Auto-close parents whose children are all done

Returns a close::CloseOutcome that describes what happened — the unit may have been closed, verify may have failed, or the close may have been blocked by a hook or feature gate.

§Errors

§Example

use mana_core::api::close_unit;
use mana_core::ops::close::{CloseOpts, CloseOutcome};
use std::path::Path;

let outcome = close_unit(Path::new("/project/.mana"), "1", CloseOpts {
    reason: Some("Implemented and tested".to_string()),
    force: false,
    defer_verify: false,
}).unwrap();

match outcome {
    CloseOutcome::Closed(r) => println!("Closed! Auto-closed parents: {:?}", r.auto_closed_parents),
    CloseOutcome::VerifyFailed(r) => eprintln!("Verify failed: {}", r.output),
    _ => {}
}