@@ -5,6 +5,7 @@ use std::fs;
55use anyhow:: { Result , Context } ;
66use clap:: Parser ;
77use colored:: Colorize ;
8+ use dialoguer:: { MultiSelect , theme:: ColorfulTheme } ;
89
910#[ derive( Debug , Deserialize ) ]
1011struct 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+
2332fn 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