use anyhow::Result;
use clap::Parser;
#[derive(Parser)]
#[command(name = "honk")]
#[command(author, version, about)]
#[command(long_about = "Make your computer honk like an old-school car.\n\n\
Run without a subcommand to honk. Drop it at the end of a long command \
(`cargo build && honk`) and your computer tells you when it is done.")]
#[command(propagate_version = true)]
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,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(clap::Subcommand)]
pub enum Commands {
Ai {
#[command(subcommand)]
command: Option<AiCommands>,
},
Completion {
#[arg(value_enum)]
shell: Shell,
},
Version,
}
#[derive(clap::Subcommand)]
pub enum AiCommands {
Test {
message: Option<String>,
},
Enable,
Disable,
Config,
Status,
}
#[derive(Clone, Copy, clap::ValueEnum)]
pub enum Shell {
Bash,
Zsh,
Fish,
Powershell,
}
impl Cli {
pub async fn run(self) -> Result<()> {
match self.command {
Some(Commands::Ai { command }) => crate::commands::ai::run(command).await,
Some(Commands::Completion { shell }) => {
crate::commands::completion::generate_completions(shell);
Ok(())
}
Some(Commands::Version) => {
crate::banner::print_banner_with_version();
Ok(())
}
None => {
println!("Honk, honk!");
Ok(())
}
}
}
}