metis_docs_cli/commands/create/
mod.rs

1mod adr;
2mod initiative;
3mod strategy;
4mod task;
5
6use crate::commands::SyncCommand;
7use anyhow::Result;
8use clap::{Args, Subcommand};
9
10#[derive(Args)]
11pub struct CreateCommand {
12    #[command(subcommand)]
13    pub document_type: CreateCommands,
14}
15
16#[derive(Subcommand)]
17pub enum CreateCommands {
18    /// Create a new strategy document
19    Strategy {
20        /// Strategy title
21        title: String,
22        /// Parent vision ID
23        #[arg(short, long)]
24        vision: Option<String>,
25    },
26    /// Create a new initiative document  
27    Initiative {
28        /// Initiative title
29        title: String,
30        /// Parent strategy ID
31        #[arg(short, long)]
32        strategy: String,
33    },
34    /// Create a new task document
35    Task {
36        /// Task title
37        title: String,
38        /// Parent initiative ID
39        #[arg(short, long)]
40        initiative: String,
41    },
42    /// Create a new ADR document
43    Adr {
44        /// ADR title
45        title: String,
46    },
47}
48
49impl CreateCommand {
50    pub async fn execute(&self) -> Result<()> {
51        match &self.document_type {
52            CreateCommands::Strategy { title, vision } => {
53                strategy::create_new_strategy(title, vision.as_deref()).await?;
54            }
55            CreateCommands::Initiative { title, strategy } => {
56                initiative::create_new_initiative(title, strategy).await?;
57            }
58            CreateCommands::Task { title, initiative } => {
59                task::create_new_task(title, initiative).await?;
60            }
61            CreateCommands::Adr { title } => {
62                adr::create_new_adr(title).await?;
63            }
64        }
65
66        // Auto-sync after creating documents to update the database index
67        println!("\nSyncing workspace...");
68        let sync_cmd = SyncCommand {};
69        sync_cmd.execute().await?;
70
71        Ok(())
72    }
73}