#[cfg_attr(not(test), expect(clippy::wildcard_imports, reason = "shared"))]
use super::*;
#[derive(Debug, Args)]
pub(super) struct ReposArgs {
#[arg(long)]
pub(super) refresh: bool,
}
#[derive(Debug, Subcommand)]
pub(super) enum BranchVerb {
List(BranchListArgs),
Switch {
#[arg(value_name = "BRANCH", value_hint = ValueHint::Other)]
name: String,
},
Create {
#[arg(value_name = "BRANCH", value_hint = ValueHint::Other)]
name: String,
#[arg(value_name = "START", value_hint = ValueHint::Other)]
start: Option<String>,
},
Rename {
#[arg(value_name = "OLD", value_hint = ValueHint::Other)]
old: String,
#[arg(value_name = "NEW", value_hint = ValueHint::Other)]
new: String,
},
Delete {
#[arg(value_name = "BRANCH", value_hint = ValueHint::Other)]
name: String,
#[arg(long)]
yes: bool,
},
Compare {
#[arg(value_name = "BRANCH", value_hint = ValueHint::Other)]
reference: String,
#[arg(long)]
expanded: bool,
},
}
#[derive(Debug, Args)]
pub(super) struct BranchListArgs {
#[arg(long)]
pub(super) all: bool,
}
#[derive(Debug, Clone, Copy, Subcommand)]
pub(super) enum WorktreeVerb {
List,
}
#[derive(Debug, Subcommand)]
pub(super) enum StashVerb {
List,
Push {
#[arg(short, long, default_value = "")]
message: String,
#[arg(long)]
include_untracked: bool,
#[arg(long, conflicts_with = "include_untracked")]
staged: bool,
#[arg(value_name = "PATH", value_hint = ValueHint::AnyPath)]
paths: Vec<PathBuf>,
},
Apply {
#[arg(value_name = "STASH", value_hint = ValueHint::Other)]
reference: String,
},
Pop {
#[arg(value_name = "STASH", value_hint = ValueHint::Other)]
reference: Option<String>,
},
Drop {
#[arg(value_name = "STASH", value_hint = ValueHint::Other)]
reference: String,
#[arg(long)]
yes: bool,
},
Clear {
#[arg(long)]
yes: bool,
},
Show {
#[arg(value_name = "STASH", value_hint = ValueHint::Other)]
reference: String,
#[arg(long)]
expanded: bool,
},
}
#[derive(Debug, Subcommand)]
pub(super) enum PrVerb {
View(PrWatchArgs),
Files(PrArgs),
Diff(PrDiffArgs),
Conversation(PrWatchArgs),
Checks(PrChecksArgs),
Logs(PrLogsArgs),
Open(PrOpenArgs),
Merge(PrMergeArgs),
Close(PrMutateArgs),
Reopen(PrMutateArgs),
}
#[derive(Debug, Args, Clone)]
pub(super) struct PrArgs {
#[arg(value_name = "NUMBER", value_hint = ValueHint::Other)]
pub(super) number: u64,
#[arg(long, value_name = "OWNER/NAME", value_hint = ValueHint::Other)]
pub(super) repo: Option<String>,
#[arg(long)]
pub(super) refresh: bool,
}
#[derive(Debug, Args)]
pub(super) struct PrWatchArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[arg(long)]
pub(super) watch: bool,
#[arg(
long,
value_name = "SECONDS",
default_value_t = CHECK_WATCH_INTERVAL,
requires = "watch",
value_parser = clap::value_parser!(u64).range(CHECK_WATCH_FLOOR..),
value_hint = ValueHint::Other
)]
pub(super) interval: u64,
}
#[derive(Debug, Args)]
pub(super) struct PrOpenArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[arg(long, value_name = "NAME", value_hint = ValueHint::Other)]
pub(super) check: Option<String>,
}
#[derive(Debug, Args)]
#[group(required = true, multiple = false)]
pub(super) struct PrMergeMethodArgs {
#[arg(long)]
pub(super) merge: bool,
#[arg(long)]
pub(super) squash: bool,
#[arg(long)]
pub(super) rebase: bool,
}
impl PrMergeMethodArgs {
pub(super) const fn method(&self) -> PullRequestMergeMethod {
if self.merge {
PullRequestMergeMethod::Merge
} else if self.rebase {
PullRequestMergeMethod::Rebase
} else {
PullRequestMergeMethod::Squash
}
}
}
#[derive(Debug, Args)]
pub(super) struct PrMergeArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[command(flatten)]
pub(super) method: PrMergeMethodArgs,
#[arg(long)]
pub(super) delete_branch: bool,
#[arg(long)]
pub(super) yes: bool,
}
#[derive(Debug, Args)]
pub(super) struct PrMutateArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[arg(long)]
pub(super) yes: bool,
}
#[derive(Debug, Args)]
pub(super) struct PrDiffArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[arg(value_name = "PATH", value_hint = ValueHint::AnyPath)]
pub(super) path: Option<PathBuf>,
}
#[derive(Debug, Args)]
pub(super) struct PrChecksArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[arg(long)]
pub(super) watch: bool,
#[arg(
long,
value_name = "SECONDS",
default_value_t = CHECK_WATCH_INTERVAL,
requires = "watch",
value_parser = clap::value_parser!(u64).range(CHECK_WATCH_FLOOR..),
value_hint = ValueHint::Other
)]
pub(super) interval: u64,
#[arg(long, conflicts_with = "watch")]
pub(super) exit_code: bool,
}
#[derive(Debug, Args)]
pub(super) struct PrLogsArgs {
#[command(flatten)]
pub(super) pull_request: PrArgs,
#[arg(value_name = "CHECK", value_hint = ValueHint::Other)]
pub(super) check: String,
#[arg(long)]
pub(super) watch: bool,
#[arg(
long,
value_name = "SECONDS",
default_value_t = LOG_WATCH_INTERVAL,
requires = "watch",
value_parser = clap::value_parser!(u64).range(LOG_WATCH_FLOOR..),
value_hint = ValueHint::Other
)]
pub(super) interval: u64,
}