use anyhow::Result; use clap::{Parser, Subcommand}; mod config; mod login; mod post; mod build; mod delete; mod refresh; mod serve; #[derive(Parser)] #[command(name = "ailog")] #[command(about = "A simple static blog generator with atproto integration")] struct Cli { #[command(subcommand)] command: Commands, } #[derive(Subcommand)] enum Commands { /// Login to atproto PDS #[command(alias = "l")] Login { /// Handle (e.g., ai.syui.ai) handle: String, /// Password #[arg(short, long)] password: String, /// PDS server (e.g., syu.is, bsky.social) #[arg(short = 's', long, default_value = "syu.is")] pds: String, }, /// Post markdown files to atproto #[command(alias = "p")] Post, /// Build static site from atproto records #[command(alias = "b")] Build, /// Delete all records from atproto #[command(alias = "d")] Delete, /// Start local preview server #[command(alias = "s")] Serve { /// Port number #[arg(short, long, default_value = "3000")] port: u16, }, } #[tokio::main] async fn main() -> Result<()> { let cli = Cli::parse(); match cli.command { Commands::Login { handle, password, pds } => { login::execute(&handle, &password, &pds).await?; } Commands::Post => { post::execute().await?; } Commands::Build => { build::execute().await?; } Commands::Delete => { delete::execute().await?; } Commands::Serve { port } => { serve::execute(port).await?; } } Ok(()) }