use std::path::PathBuf;
use clap::ArgAction;
use clap::ArgGroup;
use clap::Args;
use clap::Parser;
use clap::Subcommand;
use clap_complete::Shell;
#[derive(Args, Debug)]
pub struct GenerateShellCompletions {
#[arg(
value_enum,
long_help(
"Put generated file here :\n".to_string() +
"* Bash : add it to your bash profile in ~/.bashrc\n" +
"* Fish : see https://fishshell.com/docs/current/completions.html#where-to-put-completions\n" +
"* Powershell : see https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles\n" +
"* Others shells : don't know, MR are welcome"
)
)]
pub shell: Option<Shell>,
}
#[derive(Subcommand, Debug)]
pub enum OptionalSubcommands {
GenerateShellCompletions(GenerateShellCompletions),
}
#[derive(Parser, Debug)]
#[command(
version,
infer_subcommands = true,
subcommand_negates_reqs = true,
group = ArgGroup::new("gambling").required(true),
about(
"Blend TDD (Test Driven Development) + TCR (`test && commit || revert`) to make sure to develop\n".to_string() +
"the right thing π, baby step by baby step πΆπ¦Ά"
),
after_help(
"Any contributions (feedback, bug report, merge request ...) are welcome\n".to_string() +
"https://git-gamble.is-cool.dev/contributing/index.html"
)
)]
pub struct Cli {
#[command(subcommand)]
pub optional_subcommands: Option<OptionalSubcommands>,
#[arg(
short = 'g',
long,
group = "gambling",
visible_aliases = &["green", "refactor"],
display_order = 1,
)]
pub pass: bool,
#[arg(
short = 'r',
long,
group = "gambling",
visible_alias = "red",
display_order = 1
)]
pub fail: bool,
#[arg(short = 'n', long)]
pub dry_run: bool,
#[arg(long)]
pub no_verify: bool,
#[arg(short = 'C', long, default_value = ".")]
pub repository_path: PathBuf,
#[arg(short = 'm', long, default_value = "")]
pub message: String,
#[arg(short = 'e', long)]
pub edit: bool,
#[arg(long, group = "rebase-message")]
pub fixup: Option<String>,
#[arg(long, group = "rebase-message")]
pub squash: Option<String>,
#[arg(
env = "GAMBLE_TEST_COMMAND",
action(ArgAction::Append),
last = true,
required = true
)]
pub test_command: Vec<String>,
}
#[test]
fn verify_app() {
use clap::CommandFactory;
Cli::command().debug_assert()
}