Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Commit 321bffe

Browse files
committed
feat: Add dialoguer to run through the checklist on commit
1 parent c2999a5 commit 321bffe

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

Cargo.lock

Lines changed: 73 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ anyhow = "1.0.98"
1717
colored = "3.0.0"
1818
serde_yaml = "0.9.33"
1919
serde = { version = "1.0.219", features = ["derive"] }
20+
dialoguer = "0.11.0"
2021

2122
[dev-dependencies]
2223
serial_test = "3.2.0"

src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::fs;
55
use anyhow::{Result, Context};
66
use clap::Parser;
77
use colored::Colorize;
8+
use dialoguer::{MultiSelect, theme::ColorfulTheme};
89

910
#[derive(Debug, Deserialize)]
1011
struct DodConfig {
@@ -20,12 +21,20 @@ fn read_dod_config() -> Result<DodConfig> {
2021
Ok(config)
2122
}
2223

24+
fn run_checklist_interactive(checklist: &[String]) -> Result<bool> {
25+
let selections = MultiSelect::with_theme(&ColorfulTheme::default())
26+
.with_prompt("Please confirm each item before committing:")
27+
.items(&checklist)
28+
.interact()?;
29+
Ok(selections.len() == checklist.len())
30+
}
31+
2332
fn main() -> anyhow::Result<()> {
2433
let cli = cli::Cli::parse();
2534
let config = read_dod_config()?;
2635
if !config.checklist.is_empty() {
2736
println!("Checklist items:");
28-
for item in config.checklist {
37+
for item in config.checklist.clone() {
2938
println!("- {}", item);
3039
}
3140
} else {
@@ -44,6 +53,10 @@ fn main() -> anyhow::Result<()> {
4453
println!("{}", "Issue reference is required for commits.".red());
4554
return Err(anyhow::anyhow!("Issue reference required"));
4655
}
56+
if !run_checklist_interactive(&config.checklist)? {
57+
println!("Not all checklist items confirmed. Commit aborted.");
58+
return Ok(());
59+
}
4760
let scope_part = scope.map_or("".to_string(), |s| format!("({})", s));
4861
let header = format!("{}{}: {}", r#type, scope_part, message);
4962
let commit_message = format!("{}", header);

0 commit comments

Comments
 (0)