devbrain 0.1.0

Local-first CLI to capture, search, and recall developer workflow (commands, errors, and fixes)
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "devbrain",
    version,
    about = "Track developer notes, commands, and errors",
    long_about = "A small CLI for logging and exploring developer activity across projects."
)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    #[command(alias = "l", about = "Log a general developer note")]
    Log {
        #[arg(help = "Note content to log")]
        message: String,
    },
    #[command(alias = "lc", about = "Log a command you executed")]
    LogCmd {
        #[arg(help = "Command text to log")]
        command: String,
    },
    #[command(alias = "le", about = "Log an error message")]
    LogError {
        #[arg(help = "Error text to log")]
        error: String,
    },
    #[command(alias = "s", about = "Search past entries by keyword")]
    Search {
        #[arg(help = "Keyword to search for")]
        query: String,
        #[arg(long, help = "Include entries from all projects")]
        all: bool,
        #[arg(long, help = "Limit number of results")]
        limit: Option<usize>,
        #[arg(long, help = "Skip this many results before showing entries")]
        offset: Option<usize>,
        #[arg(long, help = "Filter by type: log, command, error")]
        entry_type: Option<String>,
    },
    #[command(alias = "t", about = "View recent activity")]
    Timeline {
        #[arg(long, help = "Include entries from all projects")]
        all: bool,
        #[arg(long, help = "Limit number of results")]
        limit: Option<usize>,
        #[arg(long, help = "Skip this many results before showing entries")]
        offset: Option<usize>,
        #[arg(long, help = "Filter by type: log, command, error")]
        entry_type: Option<String>,
    },
    #[command(about = "View recent error entries")]
    Errors {
        #[arg(long, help = "Include entries from all projects")]
        all: bool,
        #[arg(long, help = "Limit number of results")]
        limit: Option<usize>,
    },
    #[command(name = "commands", about = "View recent command entries")]
    CmdHistory {
        #[arg(long, help = "Include entries from all projects")]
        all: bool,
        #[arg(long, help = "Limit number of results")]
        limit: Option<usize>,
    },
    #[command(about = "Show the most recent entry")]
    Last {
        #[arg(long, help = "Include entries from all projects")]
        all: bool,
    },
    #[command(about = "Delete all stored entries")]
    Clear {
        #[arg(long, help = "Delete immediately without confirmation")]
        force: bool,
    },
    #[command(about = "Export all entries to a JSON file")]
    Export {
        #[arg(help = "Output file path")]
        output: String,
    },
    #[command(about = "Import entries from a JSON file")]
    Import {
        #[arg(help = "Input file path")]
        input: String,
        #[arg(long, help = "Merge imported entries with existing data")]
        merge: bool,
    },
}

pub fn parse() -> Cli {
    Cli::parse()
}