use std::io::stdout;
use clap::CommandFactory;
use clap::{Args as ClapArgs, Parser, Subcommand};
use clap_complete::{generate, Shell};
#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Args {
#[arg(long, group = "mode")]
pub list: bool,
#[arg(long, group = "mode")]
pub select: bool,
#[arg(long)]
pub format: Option<String>,
#[arg(long, short = 'n', value_name = "number")]
pub max_count: Option<u32>,
#[arg(long, short = 'a', group = "rev_range")]
pub all: bool,
#[arg(long, short = 'l', group = "rev_range")]
pub local: bool,
#[arg(long, group = "autorebase")]
pub rebase: bool,
#[arg(long, group = "autorebase")]
pub no_rebase: bool,
#[arg(long, short = 'i')]
pub interactive: bool,
#[arg(long, group = "list_blame")]
pub blame: bool,
#[arg(long, group = "list_blame")]
pub no_blame: bool,
#[arg(long, group = "list_files")]
pub files: bool,
#[arg(long, group = "list_files")]
pub no_files: bool,
#[arg(long, value_name = "number")]
pub recent: Option<u32>,
#[arg(long, group = "rev_range", value_name = "revision-range")]
pub range: Option<String>,
#[arg(long, group = "fixup_mode")]
pub amend: bool,
#[arg(long, group = "fixup_mode")]
pub reword: bool,
pub commit: Option<String>,
#[command(subcommand)]
pub subcommand: Option<SubCommand>,
}
#[derive(Debug, Subcommand)]
pub enum SubCommand {
#[clap(name = "completions")]
Completions(Completions),
}
#[derive(Debug, ClapArgs)]
pub struct Completions {
pub shell: Shell,
}
pub fn gen_completions(completions: &Completions) {
let mut cmd = Args::command();
let bin_name = cmd.get_name().to_string();
generate(completions.shell, &mut cmd, &bin_name, &mut stdout());
}