diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index 68d356ed..c6675d12 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -1,5 +1,6 @@ #![allow(clippy::or_fun_call)] use std::ffi::OsString; +use std::io; use std::str::FromStr; use anyhow::{anyhow, Context as _}; @@ -464,7 +465,9 @@ fn prompt_issue( title }; let description = if description.is_empty() { - "Enter a description..." + "" } else { description }; @@ -500,10 +503,28 @@ fn prompt_issue( } } - let description: String = lines.collect::>().join("\n"); - let meta: Metadata = + let mut meta: Metadata = serde_yaml::from_str(&meta).context("failed to parse yaml front-matter")?; + meta.title = meta.title.trim().to_string(); + if meta.title.is_empty() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "an issue title must be provided", + ) + .into()); + } + + let description: String = lines.collect::>().join("\n"); + let description = term::format::strip_comments(&description); + if description.is_empty() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "an issue description must be provided", + ) + .into()); + } + Ok(Some((meta, description))) }