Skip to content

Commit 04a1093

Browse files
authored
feat: support options in workflow dispatch (#189)
* Add `options` to `WorkflowDispatchInput` * Add setters
1 parent 8996df9 commit 04a1093

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/gh-workflow/src/event.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,25 @@ pub struct WorkflowDispatchInput {
915915
pub input_type: String,
916916
/// Default value for the input
917917
#[serde(skip_serializing_if = "Option::is_none")]
918+
#[setters(skip)]
918919
pub default: Option<String>,
920+
/// The options of the dropdown list, if the type is a choice
921+
#[serde(skip_serializing_if = "Vec::is_empty")]
922+
#[setters(skip)]
923+
pub options: Vec<String>,
924+
}
925+
926+
impl WorkflowDispatchInput {
927+
pub fn set_default(self, value: impl Into<String>) -> Self {
928+
Self { default: Some(value.into()), ..self }
929+
}
930+
931+
pub fn options<T: ToString, I: IntoIterator<Item = T>>(self, iter: I) -> Self {
932+
Self {
933+
options: iter.into_iter().map(|v| v.to_string()).collect(),
934+
..self
935+
}
936+
}
919937
}
920938

921939
/// Types of workflow run events

0 commit comments

Comments
 (0)