KDTQAQLO2CBYBW4RJWWGO63NHXJWZNZUTZW44BI7IFFLQSLLVZ7QC
impl Default for Dialog {
fn default() -> Self {
Self {
r#type: String::default(),
scope: String::default(),
description: String::default(),
body: "# A longer commit body MAY be provided after the short description, \n\
# providing additional contextual information about the code changes. \n\
# The body MUST begin one blank line after the description. \n\
# A commit body is free-form and MAY consist of any number of newline separated paragraphs.\n".to_string(),
breaking_change: String::default(),
issues: String::default(),
}
}
}
loop {
// type
let current_type = dialog.r#type.as_str();
match (r#type.as_ref(), current_type) {
(Some(t), "") if t != "" => dialog.r#type = t.to_owned(),
(_, t) => {
dialog.r#type = Self::select_type(theme, t, types)?;
}
// type
let current_type = dialog.r#type.as_str();
match (r#type.as_ref(), current_type) {
(Some(t), "") if t != "" => dialog.r#type = t.to_owned(),
(_, t) => {
dialog.r#type = Self::select_type(theme, t, types)?;
// scope
dialog.scope = read_scope(theme, dialog.scope.as_ref(), scope_regex.clone())?;
// description
dialog.description = read_description(theme, dialog.description)?;
// body
dialog.body = read_body(dialog.body.as_str())?;
// breaking change
dialog.breaking_change = read_single_line(
theme,
"optional BREAKING change",
dialog.breaking_change.as_str(),
)?;
// issues
dialog.issues =
read_single_line(theme, "issues (e.g. #2, #8)", dialog.issues.as_str())?;
}
// scope
dialog.scope = read_scope(theme, dialog.scope.as_ref(), scope_regex)?;
// description
dialog.description = read_description(theme, dialog.description)?;
// breaking change
dialog.breaking_change = read_single_line(
theme,
"optional BREAKING change",
dialog.breaking_change.as_str(),
)?;
// issues
dialog.issues = read_single_line(theme, "issues (e.g. #2, #8)", dialog.issues.as_str())?;
loop {
match make_commit_message(&dialog, breaking, &parser) {
Ok(msg) => {
if dialoguer::Confirm::with_theme(theme)
.with_prompt(format!("\nConfirm commit message:\n\n{}\n", msg))
let msg = make_commit_message(&dialog, breaking);
let msg = edit_message(msg.as_str())?;
match parser.parse(msg.as_str()).map(|_| msg) {
Ok(msg) => break Ok(msg),
Err(e) => {
eprintln!("ParseError: {}", e);
if !dialoguer::Confirm::new()
.with_prompt("Continue?")