@@ -57,19 +57,18 @@ enum Operation {
57
57
/// Parsed command line options.
58
58
#[ derive( Clone , Debug , Default ) ]
59
59
struct CliOptions {
60
- skip_children : bool ,
60
+ skip_children : Option < bool > ,
61
61
verbose : bool ,
62
62
write_mode : Option < WriteMode > ,
63
63
color : Option < Color > ,
64
64
file_lines : FileLines , // Default is all lines in all files.
65
65
unstable_features : bool ,
66
- error_on_unformatted : bool ,
66
+ error_on_unformatted : Option < bool > ,
67
67
}
68
68
69
69
impl CliOptions {
70
70
fn from_matches ( matches : & Matches ) -> FmtResult < CliOptions > {
71
71
let mut options = CliOptions :: default ( ) ;
72
- options. skip_children = matches. opt_present ( "skip-children" ) ;
73
72
options. verbose = matches. opt_present ( "verbose" ) ;
74
73
let unstable_features = matches. opt_present ( "unstable-features" ) ;
75
74
let rust_nightly = option_env ! ( "CFG_RELEASE_CHANNEL" )
@@ -105,19 +104,26 @@ impl CliOptions {
105
104
options. file_lines = file_lines. parse ( ) ?;
106
105
}
107
106
107
+ if matches. opt_present ( "skip-children" ) {
108
+ options. skip_children = Some ( true ) ;
109
+ }
108
110
if matches. opt_present ( "error-on-unformatted" ) {
109
- options. error_on_unformatted = true ;
111
+ options. error_on_unformatted = Some ( true ) ;
110
112
}
111
113
112
114
Ok ( options)
113
115
}
114
116
115
117
fn apply_to ( self , config : & mut Config ) {
116
- config. set ( ) . skip_children ( self . skip_children ) ;
117
118
config. set ( ) . verbose ( self . verbose ) ;
118
119
config. set ( ) . file_lines ( self . file_lines ) ;
119
120
config. set ( ) . unstable_features ( self . unstable_features ) ;
120
- config. set ( ) . error_on_unformatted ( self . error_on_unformatted ) ;
121
+ if let Some ( skip_children) = self . skip_children {
122
+ config. set ( ) . skip_children ( skip_children) ;
123
+ }
124
+ if let Some ( error_on_unformatted) = self . error_on_unformatted {
125
+ config. set ( ) . error_on_unformatted ( error_on_unformatted) ;
126
+ }
121
127
if let Some ( write_mode) = self . write_mode {
122
128
config. set ( ) . write_mode ( write_mode) ;
123
129
}
0 commit comments