use std::path::PathBuf;
use clap::{ArgAction, Parser, Subcommand, ValueEnum};
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum OutputFormat {
Json,
}
#[derive(Debug, Subcommand)]
pub enum GitwaySubcommand {
Schema,
Describe,
}
#[derive(Debug, Parser)]
#[expect(
clippy::struct_excessive_bools,
reason = "CLI flag structs naturally accumulate boolean flags; grouping them \
into a bitflag or sub-struct would not aid clarity here."
)]
#[command(
name = "gitway",
version,
about = "Purpose-built SSH transport client for Git operations against GitHub, GitLab, and Codeberg.",
long_about = None,
// Allow unknown arguments beginning with `-o` for OpenSSH compatibility.
// Any unrecognised args are collected into `extra_opts` below.
allow_hyphen_values = true,
// When a subcommand name is provided (e.g. `gitway schema`), the
// `host` positional arg requirement is automatically waived.
subcommand_negates_reqs = true,
// A word matching a subcommand name (e.g. "schema") is treated as a
// subcommand even when positional args are also defined.
subcommand_precedence_over_arg = true,
)]
pub struct Cli {
#[command(subcommand)]
pub subcommand: Option<GitwaySubcommand>,
#[arg(index = 1, required_unless_present_any = ["test", "install"])]
pub host: Option<String>,
#[arg(index = 2, num_args = 1.., trailing_var_arg = true)]
pub command: Vec<String>,
#[arg(short = 'i', long = "identity", value_name = "FILE")]
pub identity: Option<PathBuf>,
#[arg(long = "cert", value_name = "FILE")]
pub cert: Option<PathBuf>,
#[arg(short = 'p', long = "port", value_name = "PORT", default_value_t = 22)]
pub port: u16,
#[arg(long = "insecure-skip-host-check", action = ArgAction::SetTrue)]
pub insecure_skip_host_check: bool,
#[arg(long = "json", action = ArgAction::SetTrue, overrides_with = "format")]
pub json: bool,
#[arg(long = "format", value_enum, value_name = "FORMAT")]
pub format: Option<OutputFormat>,
#[arg(long = "no-color", action = ArgAction::SetTrue)]
pub no_color: bool,
#[arg(short = 'v', long = "verbose", action = ArgAction::SetTrue)]
pub verbose: bool,
#[arg(long = "test", action = ArgAction::SetTrue, conflicts_with = "install")]
pub test: bool,
#[arg(long = "install", action = ArgAction::SetTrue, conflicts_with = "test")]
pub install: bool,
#[arg(short = 'o', value_name = "KEY=VALUE", action = ArgAction::Append, hide = true)]
pub compat_opts: Vec<String>,
}