agileplus-cli 0.3.0

Typed intent graphs for engineering work — convert prompts into validated DAGs of intents, features, tasks, tests, and edges, then store, query, and serve them from Rust, HTTP, or MCP.
use std::io::Write;
use std::path::PathBuf;

use agileplus_sqlite::Storage;
use anyhow::{Context, Result};
use clap::Args;

/// Delete an intent graph from a SQLite database.
#[derive(Debug, Args)]
#[command(name = "delete")]
pub struct DeleteCommand {
    /// Path to the SQLite database.
    #[arg(short, long)]
    db: PathBuf,

    /// Id of the graph to delete.
    #[arg(short, long)]
    id: String,

    /// Skip the interactive confirmation prompt.
    #[arg(short, long)]
    force: bool,
}

impl DeleteCommand {
    pub fn run(&self) -> Result<()> {
        if !self.force {
            eprint!("Delete graph '{}' from {}? [y/N] ", self.id, self.db.display());
            std::io::stderr().flush().ok();
            let mut answer = String::new();
            std::io::stdin().read_line(&mut answer).ok();
            if !matches!(answer.trim().to_ascii_lowercase().as_str(), "y" | "yes") {
                println!("aborted");
                return Ok(());
            }
        }

        let storage = Storage::open(&self.db)
            .with_context(|| format!("Failed to open storage at: {}", self.db.display()))?;

        let removed = storage
            .delete_graph(&self.id)
            .with_context(|| format!("Failed to delete graph: {}", self.id))?;

        if removed {
            println!("deleted: {}", self.id);
        } else {
            println!("not found: {}", self.id);
        }
        Ok(())
    }
}