diff --git a/src/nostr_utils/utils.rs b/src/nostr_utils/utils.rs index 4a77c72..6158fe1 100644 --- a/src/nostr_utils/utils.rs +++ b/src/nostr_utils/utils.rs @@ -184,3 +184,14 @@ pub fn read_editor(file_suffix: &str) -> N34Result { } Ok(content) } + +/// Returns the given content if it's `Option::Some` or call [`read_editor`] +pub fn get_content(content: Option, file_suffix: &str) -> N34Result +where + S: AsRef, +{ + if let Some(content) = content { + return Ok(content.as_ref().trim().to_owned()); + } + read_editor(file_suffix) +}