use clap::Args;
use clap::ValueEnum;
use crate::cli::graph::GraphArgs;
use crate::forge::comment::StackPlacement;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Deserialize, clap::ValueEnum)]
#[serde(rename_all = "kebab-case")]
pub enum PrMode {
#[default]
Regular,
Draft,
}
impl std::fmt::Display for PrMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let pv = self
.to_possible_value()
.expect("all variants have possible values");
f.write_str(pv.get_name())
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Deserialize, clap::ValueEnum)]
#[serde(rename_all = "kebab-case")]
pub enum SyncPrContent {
#[default]
None,
Title,
Body,
All,
}
impl std::fmt::Display for SyncPrContent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let pv = self
.to_possible_value()
.expect("all variants have possible values");
f.write_str(pv.get_name())
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Deserialize, clap::ValueEnum)]
#[serde(rename_all = "kebab-case")]
pub enum TrailerHandling {
#[default]
Keep,
Strip,
}
impl std::fmt::Display for TrailerHandling {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let pv = self
.to_possible_value()
.expect("all variants have possible values");
f.write_str(pv.get_name())
}
}
#[derive(Debug, Args)]
pub struct SubmitArgs {
pub bookmark: Option<String>,
#[arg(long)]
pub dry_run: bool,
#[command(flatten)]
pub graph: GraphArgs,
#[arg(
long,
env = "STAKK_PR_MODE",
default_value = "regular",
value_enum,
verbatim_doc_comment
)]
pub pr_mode: PrMode,
#[arg(long, env = "STAKK_DRAFT")]
draft: bool,
#[arg(long, default_value = "origin", env = "STAKK_REMOTE")]
pub remote: String,
#[expect(
clippy::doc_lazy_continuation,
reason = "endfor must align with the for-loop, not the list item"
)]
#[arg(long, env = "STAKK_TEMPLATE", verbatim_doc_comment)]
pub template: Option<String>,
#[arg(
long,
env = "STAKK_STACK_PLACEMENT",
default_value = "comment",
value_enum,
verbatim_doc_comment
)]
pub stack_placement: StackPlacement,
#[arg(
long,
env = "STAKK_SYNC_PR_CONTENT",
default_value = "none",
value_enum,
verbatim_doc_comment
)]
pub sync_pr_content: SyncPrContent,
#[arg(
long,
env = "STAKK_TRAILERS",
default_value = "keep",
value_enum,
verbatim_doc_comment
)]
pub trailers: TrailerHandling,
#[arg(long, env = "STAKK_AUTO_PREFIX", verbatim_doc_comment)]
pub auto_prefix: Option<String>,
#[arg(long, env = "STAKK_BOOKMARK_COMMAND", verbatim_doc_comment)]
pub bookmark_command: Option<String>,
}
impl SubmitArgs {
pub fn pr_mode(&self) -> PrMode {
if self.draft {
PrMode::Draft
} else {
self.pr_mode
}
}
}