use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
#[arg(short, long)]
pub provider: Option<String>,
#[arg(short, long)]
pub model: Option<String>,
#[arg(long)]
pub dry_run: bool,
#[arg(short, long)]
pub review: bool,
#[arg(short, long)]
pub force: bool,
#[arg(short, long)]
pub verbose: bool,
#[arg(long)]
pub include_files: bool,
#[arg(short = 's', long)]
pub show_command: bool,
#[arg(long)]
pub legacy: bool,
#[arg(short = 'y', long)]
pub yes: bool,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Setup,
List,
Config,
}
#[cfg(test)]
mod tests {
use super::*;
use clap::Parser;
#[test]
fn test_cli_parse_provider_and_model() {
let args = vec!["prog", "--provider", "openai", "--model", "gpt-4o"];
let cli = Cli::parse_from(args);
assert_eq!(cli.provider, Some("openai".to_string()));
assert_eq!(cli.model, Some("gpt-4o".to_string()));
}
#[test]
fn test_cli_parse_dry_run_and_force() {
let args = vec!["prog", "--dry-run", "--force"];
let cli = Cli::parse_from(args);
assert!(cli.dry_run);
assert!(cli.force);
}
#[test]
fn test_cli_parse_setup_command() {
let args = vec!["prog", "setup"];
let cli = Cli::parse_from(args);
match cli.command {
Some(Commands::Setup) => {}
_ => panic!("Expected Setup command"),
}
}
}