use clap::{Parser, Subcommand};
pub mod agent_init;
pub mod board;
pub mod config;
pub mod export;
pub mod import;
pub mod init;
pub mod issue;
pub mod next;
pub mod plan;
pub mod stats;
pub mod truncate;
pub mod version;
pub mod web;
#[derive(Parser)]
#[command(name = "bmo", about = "Local-first issue tracker for AI agents")]
pub struct Cli {
#[arg(long, global = true)]
pub json: bool,
#[arg(long, global = true, env = "BMO_DB")]
pub db: Option<String>,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
Init(init::InitArgs),
Config(config::ConfigArgs),
Version,
Stats,
Export(export::ExportArgs),
Import(import::ImportArgs),
Board(board::BoardArgs),
Next(next::NextArgs),
Plan(plan::PlanArgs),
Web(web::WebArgs),
Truncate(truncate::TruncateArgs),
AgentInit(agent_init::AgentInitArgs),
#[command(subcommand)]
Issue(issue::IssueCommands),
}
#[allow(dead_code)]
pub fn parse_id(s: &str) -> anyhow::Result<i64> {
let stripped = s
.trim()
.to_uppercase()
.strip_prefix("BMO-")
.map(|s| s.to_string())
.unwrap_or_else(|| s.trim().to_string());
stripped
.parse::<i64>()
.map_err(|_| anyhow::anyhow!("invalid issue ID: {s}"))
}