Implement CLI send flows and refactor plugin event handling

This commit is contained in:
Gregory Schier
2026-02-17 15:41:09 -08:00
parent 1f588d0498
commit a4f96fca11
29 changed files with 1587 additions and 252 deletions

View File

@@ -25,9 +25,9 @@ pub fn parse_optional_json(
context: &str,
) -> JsonResult<Option<Value>> {
match (json_flag, json_shorthand) {
(Some(_), Some(_)) => Err(format!(
"Cannot provide both --json and positional JSON for {context}"
)),
(Some(_), Some(_)) => {
Err(format!("Cannot provide both --json and positional JSON for {context}"))
}
(Some(raw), None) => parse_json_object(&raw, context).map(Some),
(None, Some(raw)) => parse_json_object(&raw, context).map(Some),
(None, None) => Ok(None),
@@ -39,9 +39,8 @@ pub fn parse_required_json(
json_shorthand: Option<String>,
context: &str,
) -> JsonResult<Value> {
parse_optional_json(json_flag, json_shorthand, context)?.ok_or_else(|| {
format!("Missing JSON payload for {context}. Use --json or positional JSON")
})
parse_optional_json(json_flag, json_shorthand, context)?
.ok_or_else(|| format!("Missing JSON payload for {context}. Use --json or positional JSON"))
}
pub fn require_id(payload: &Value, context: &str) -> JsonResult<String> {
@@ -60,9 +59,7 @@ pub fn validate_create_id(payload: &Value, context: &str) -> JsonResult<()> {
match id_value {
Value::String(id) if id.is_empty() => Ok(()),
_ => Err(format!(
"{context} create JSON must omit \"id\" or set it to an empty string"
)),
_ => Err(format!("{context} create JSON must omit \"id\" or set it to an empty string")),
}
}