1- use ext :: IntoContext ;
1+ use error_stack_ext :: IntoContext ;
22use ownership:: Ownership ;
33
44use crate :: project:: Project ;
@@ -13,7 +13,7 @@ use std::{
1313} ;
1414
1515mod config;
16- mod ext ;
16+ mod error_stack_ext ;
1717mod ownership;
1818mod project;
1919
@@ -85,7 +85,7 @@ impl Context for Error {}
8585
8686fn main ( ) -> Result < ( ) , Error > {
8787 install_logger ( ) ;
88- print_validation_errors_to_stdout ( cli ( ) ) ?;
88+ maybe_print_errors ( cli ( ) ) ?;
8989
9090 Ok ( ( ) )
9191}
@@ -99,14 +99,13 @@ fn cli() -> Result<(), Error> {
9999
100100 let config_file = File :: open ( & config_path)
101101 . into_context ( Error :: Io )
102- . attach_printable ( format ! ( "{}" , config_path. to_string_lossy( ) ) ) ?;
102+ . attach_printable ( format ! ( "Can't open config file: {}" , config_path. to_string_lossy( ) ) ) ?;
103103
104104 let config = serde_yaml:: from_reader ( config_file) . into_context ( Error :: Io ) ?;
105105
106106 let ownership = Ownership :: build ( Project :: build ( & project_root, & codeowners_file_path, & config) . change_context ( Error :: Io ) ?) ;
107- let command = args. command ;
108107
109- match command {
108+ match args . command {
110109 Command :: Validate => ownership. validate ( ) . into_context ( Error :: ValidationFailed ) ?,
111110 Command :: Generate => {
112111 std:: fs:: write ( codeowners_file_path, ownership. generate_file ( ) ) . into_context ( Error :: Io ) ?;
@@ -120,7 +119,7 @@ fn cli() -> Result<(), Error> {
120119 Ok ( ( ) )
121120}
122121
123- fn print_validation_errors_to_stdout ( result : Result < ( ) , Error > ) -> Result < ( ) , Error > {
122+ fn maybe_print_errors ( result : Result < ( ) , Error > ) -> Result < ( ) , Error > {
124123 if let Err ( error) = result {
125124 if let Some ( validation_errors) = error. downcast_ref :: < ownership:: ValidatorErrors > ( ) {
126125 println ! ( "{}" , validation_errors) ;
0 commit comments