use clap::{Parser, Subcommand, ValueEnum};
#[derive(Parser)]
#[command(
name = "pidge",
version,
about = "The e-mail and calendar client for your AI agent",
long_about = "The e-mail and calendar client for your AI agent.\n\n\
Microsoft 365, Outlook.com and Gmail, merged. Built to be driven by AI agents (see `pidge skill`), \
pleasant by hand. Without a command, pidge shows what's new and today's calendar."
)]
pub struct Cli {
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub verbose: u8,
#[arg(short, long, global = true)]
pub quiet: bool,
#[arg(long, global = true)]
pub no_color: bool,
#[arg(long, global = true)]
pub json: bool,
#[arg(long, global = true, hide = true)]
pub dry_run: bool,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand)]
pub enum Commands {
Account {
#[command(subcommand)]
command: AccountCommands,
},
Mcp {
#[command(subcommand)]
command: McpCommands,
},
Ai {
#[command(subcommand)]
command: Option<AiCommands>,
},
Skill {
#[arg(long)]
from_source: bool,
},
Op {
name: Option<String>,
#[arg(long)]
input: Option<String>,
#[arg(long)]
list: bool,
},
#[command(hide = true)]
Outbox {
#[command(subcommand)]
command: OutboxCommands,
},
#[command(hide = true)]
Debug {
#[command(subcommand)]
command: DebugCommands,
},
Completion {
#[arg(value_enum)]
shell: Shell,
},
Version,
}
#[derive(Subcommand)]
pub enum AccountCommands {
Add {
#[arg(long, value_enum, default_value_t = ProviderArg::Microsoft)]
provider: ProviderArg,
#[arg(long, value_enum, default_value_t = StorageBackendArg::Keychain)]
store: StorageBackendArg,
},
List,
Remove {
email: Option<String>,
#[arg(long, conflicts_with = "email")]
all: bool,
#[arg(short = 'y', long)]
yes: bool,
},
MigrateStorage {
email: String,
#[arg(long = "to", value_enum)]
to: StorageBackendArg,
},
}
#[derive(Subcommand)]
pub enum McpCommands {
Serve,
Connect {
url: String,
#[arg(long, value_enum, default_value_t = StorageBackendArg::Keychain)]
store: StorageBackendArg,
#[arg(short = 'y', long)]
yes: bool,
},
Status {
url: Option<String>,
#[arg(long, value_enum)]
store: Option<StorageBackendArg>,
},
Logout {
url: String,
#[arg(long, value_enum)]
store: Option<StorageBackendArg>,
},
}
#[derive(Subcommand)]
pub enum AiCommands {
Config,
Enable,
Disable,
Status,
Test { message: Option<String> },
}
#[derive(Subcommand)]
pub enum DebugCommands {
RawHtml {
id: String,
},
}
#[derive(Subcommand)]
pub enum OutboxCommands {
Run,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum ProviderArg {
Microsoft,
Google,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum StorageBackendArg {
Keychain,
File,
}
impl From<StorageBackendArg> for pidge_core::TokenStorage {
fn from(v: StorageBackendArg) -> Self {
match v {
StorageBackendArg::Keychain => Self::Keychain,
StorageBackendArg::File => Self::File,
}
}
}
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum Shell {
Bash,
Zsh,
Fish,
Powershell,
}