chore(nostr): A util to get the content from a string or editor

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-05-18 08:59:05 +00:00
parent 661266c67b
commit 074245733e

View File

@@ -184,3 +184,14 @@ pub fn read_editor(file_suffix: &str) -> N34Result<String> {
} }
Ok(content) Ok(content)
} }
/// Returns the given content if it's `Option::Some` or call [`read_editor`]
pub fn get_content<S>(content: Option<S>, file_suffix: &str) -> N34Result<String>
where
S: AsRef<str>,
{
if let Some(content) = content {
return Ok(content.as_ref().trim().to_owned());
}
read_editor(file_suffix)
}