11mod cli;
22mod git;
3+ use serde:: Deserialize ;
4+ use std:: fs;
5+ use anyhow:: { Result , Context } ;
36use clap:: Parser ;
47use colored:: Colorize ;
58
9+ #[ derive( Debug , Deserialize ) ]
10+ struct DodConfig {
11+ issue_reference_required : Option < bool > ,
12+ checklist : Vec < String > ,
13+ }
14+
15+ fn read_dod_config ( ) -> Result < DodConfig > {
16+ let content = fs:: read_to_string ( ".dod.yml" )
17+ . context ( "Failed to read .dod.yml" ) ?;
18+ let config: DodConfig = serde_yaml:: from_str ( & content)
19+ . context ( "Failed to parse .dod.yml" ) ?;
20+ Ok ( config)
21+ }
22+
623fn main ( ) -> anyhow:: Result < ( ) > {
724 let cli = cli:: Cli :: parse ( ) ;
25+ let config = read_dod_config ( ) ?;
26+ if !config. checklist . is_empty ( ) {
27+ println ! ( "Checklist items:" ) ;
28+ for item in config. checklist {
29+ println ! ( "- {}" , item) ;
30+ }
31+ } else {
32+ println ! ( "{}" , "No checklist items defined." . yellow( ) ) ;
33+ }
34+
835 match cli. command {
936 cli:: Commands :: Status => {
1037 println ! ( "--- Checking Git status ---" ) ;
@@ -13,6 +40,10 @@ fn main() -> anyhow::Result<()> {
1340 }
1441 cli:: Commands :: Commit { r#type, scope, message} => {
1542 println ! ( "--- Committing changes ---" ) ;
43+ if config. issue_reference_required . unwrap_or ( false ) {
44+ println ! ( "{}" , "Issue reference is required for commits." . red( ) ) ;
45+ return Err ( anyhow:: anyhow!( "Issue reference required" ) ) ;
46+ }
1647 let scope_part = scope. map_or ( "" . to_string ( ) , |s| format ! ( "({})" , s) ) ;
1748 let header = format ! ( "{}{}: {}" , r#type, scope_part, message) ;
1849 let commit_message = format ! ( "{}" , header) ;
0 commit comments