chant/operations/
reset.rs1use anyhow::Result;
6use std::path::Path;
7
8use crate::spec::{Spec, SpecStatus};
9
10#[derive(Debug, Clone, Default)]
12pub struct ResetOptions {
13 pub re_execute: bool,
15 pub prompt: Option<String>,
17 pub branch: Option<String>,
19}
20
21pub fn reset_spec(spec: &mut Spec, spec_path: &Path, _options: ResetOptions) -> Result<()> {
26 if spec.frontmatter.status != SpecStatus::Failed
28 && spec.frontmatter.status != SpecStatus::InProgress
29 {
30 anyhow::bail!(
31 "Spec '{}' is not in failed or in_progress state (current: {:?}). \
32 Only failed or in_progress specs can be reset.",
33 spec.id,
34 spec.frontmatter.status
35 );
36 }
37
38 spec.set_status(SpecStatus::Pending)
40 .map_err(|e| anyhow::anyhow!("Failed to transition spec to Pending: {}", e))?;
41
42 spec.save(spec_path)?;
44
45 Ok(())
46}