File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -110,17 +110,18 @@ fn match_cli_path_or_file(config_path: Option<PathBuf>,
110
110
resolve_config ( input_file)
111
111
}
112
112
113
- fn update_config ( config : & mut Config , matches : & Matches ) {
113
+ fn update_config ( config : & mut Config , matches : & Matches ) -> Result < ( ) , String > {
114
114
config. verbose = matches. opt_present ( "verbose" ) ;
115
115
config. skip_children = matches. opt_present ( "skip-children" ) ;
116
116
117
- let write_mode = matches. opt_str ( "write-mode" ) . map ( |ref s| {
118
- WriteMode :: from_str ( s) . expect ( & format ! ( "Invalid write-mode: {}" , s) )
119
- } ) ;
120
-
121
- if let Some ( write_mode) = write_mode {
122
- config. write_mode = write_mode;
117
+ if let Some ( write_mode) = matches. opt_str ( "write-mode" ) {
118
+ match WriteMode :: from_str ( & write_mode) {
119
+ Ok ( write_mode) => config. write_mode = write_mode,
120
+ Err ( _) => return Err ( format ! ( "Invalid write-mode: {}" , write_mode) ) ,
121
+ }
123
122
}
123
+
124
+ Ok ( ( ) )
124
125
}
125
126
126
127
fn execute ( ) -> i32 {
@@ -210,7 +211,10 @@ fn execute() -> i32 {
210
211
config = config_tmp;
211
212
}
212
213
213
- update_config ( & mut config, & matches) ;
214
+ if let Err ( e) = update_config ( & mut config, & matches) {
215
+ print_usage ( & opts, & e) ;
216
+ return 1 ;
217
+ }
214
218
run ( & file, & config) ;
215
219
}
216
220
0
You can’t perform that action at this time.
0 commit comments