fix: Optional input

This commit is contained in:
J H
2024-07-25 13:25:18 -06:00
parent 099b77cf9b
commit 1a0536d212
6 changed files with 35 additions and 9 deletions

View File

@@ -58,6 +58,7 @@ pub struct ActionParams {
pub action_id: ActionId,
#[command(flatten)]
#[ts(type = "{ [key: string]: any } | null")]
#[serde(default)]
pub input: StdinDeserializable<Option<Config>>,
}
// impl C

View File

@@ -568,6 +568,14 @@ where
#[derive(Deserialize, Serialize, TS)]
pub struct StdinDeserializable<T>(pub T);
impl<T> Default for StdinDeserializable<T>
where
T: Default,
{
fn default() -> Self {
Self(T::default())
}
}
impl<T> FromArgMatches for StdinDeserializable<T>
where
T: DeserializeOwned,