@@ -263,24 +263,35 @@ fn format_string(input: String, options: GetOptsOptions) -> Result<i32> {
263
263
let ( mut config, _) = load_config ( Some ( Path :: new ( "." ) ) , Some ( options. clone ( ) ) ) ?;
264
264
265
265
if options. check {
266
- config. set ( ) . emit_mode ( EmitMode :: Diff ) ;
266
+ config. set_cli ( ) . emit_mode ( EmitMode :: Diff ) ;
267
267
} else {
268
268
match options. emit_mode {
269
269
// Emit modes which work with standard input
270
270
// None means default, which is Stdout.
271
- None | Some ( EmitMode :: Stdout ) | Some ( EmitMode :: Checkstyle ) | Some ( EmitMode :: Json ) => { }
271
+ None => {
272
+ config
273
+ . set ( )
274
+ . emit_mode ( options. emit_mode . unwrap_or ( EmitMode :: Stdout ) ) ;
275
+ }
276
+ Some ( EmitMode :: Stdout ) | Some ( EmitMode :: Checkstyle ) | Some ( EmitMode :: Json ) => {
277
+ config
278
+ . set_cli ( )
279
+ . emit_mode ( options. emit_mode . unwrap_or ( EmitMode :: Stdout ) ) ;
280
+ }
272
281
Some ( emit_mode) => {
273
282
return Err ( OperationError :: StdinBadEmit ( emit_mode) . into ( ) ) ;
274
283
}
275
284
}
276
- config
277
- . set ( )
278
- . emit_mode ( options. emit_mode . unwrap_or ( EmitMode :: Stdout ) ) ;
279
285
}
280
286
config. set ( ) . verbose ( Verbosity :: Quiet ) ;
281
287
282
288
// parse file_lines
283
- config. set ( ) . file_lines ( options. file_lines ) ;
289
+ if options. file_lines . is_all ( ) {
290
+ config. set ( ) . file_lines ( options. file_lines ) ;
291
+ } else {
292
+ config. set_cli ( ) . file_lines ( options. file_lines ) ;
293
+ }
294
+
284
295
for f in config. file_lines ( ) . files ( ) {
285
296
match * f {
286
297
FileName :: Stdin => { }
@@ -650,36 +661,46 @@ impl GetOptsOptions {
650
661
impl CliOptions for GetOptsOptions {
651
662
fn apply_to ( self , config : & mut Config ) {
652
663
if self . verbose {
653
- config. set ( ) . verbose ( Verbosity :: Verbose ) ;
664
+ config. set_cli ( ) . verbose ( Verbosity :: Verbose ) ;
654
665
} else if self . quiet {
655
- config. set ( ) . verbose ( Verbosity :: Quiet ) ;
666
+ config. set_cli ( ) . verbose ( Verbosity :: Quiet ) ;
656
667
} else {
657
668
config. set ( ) . verbose ( Verbosity :: Normal ) ;
658
669
}
659
- config. set ( ) . file_lines ( self . file_lines ) ;
660
- config. set ( ) . unstable_features ( self . unstable_features ) ;
670
+
671
+ if self . file_lines . is_all ( ) {
672
+ config. set ( ) . file_lines ( self . file_lines ) ;
673
+ } else {
674
+ config. set_cli ( ) . file_lines ( self . file_lines ) ;
675
+ }
676
+
677
+ if self . unstable_features {
678
+ config. set_cli ( ) . unstable_features ( self . unstable_features ) ;
679
+ } else {
680
+ config. set ( ) . unstable_features ( self . unstable_features ) ;
681
+ }
661
682
if let Some ( skip_children) = self . skip_children {
662
- config. set ( ) . skip_children ( skip_children) ;
683
+ config. set_cli ( ) . skip_children ( skip_children) ;
663
684
}
664
685
if let Some ( error_on_unformatted) = self . error_on_unformatted {
665
- config. set ( ) . error_on_unformatted ( error_on_unformatted) ;
686
+ config. set_cli ( ) . error_on_unformatted ( error_on_unformatted) ;
666
687
}
667
688
if let Some ( edition) = self . edition {
668
- config. set ( ) . edition ( edition) ;
689
+ config. set_cli ( ) . edition ( edition) ;
669
690
}
670
691
if self . check {
671
- config. set ( ) . emit_mode ( EmitMode :: Diff ) ;
692
+ config. set_cli ( ) . emit_mode ( EmitMode :: Diff ) ;
672
693
} else if let Some ( emit_mode) = self . emit_mode {
673
- config. set ( ) . emit_mode ( emit_mode) ;
694
+ config. set_cli ( ) . emit_mode ( emit_mode) ;
674
695
}
675
696
if self . backup {
676
- config. set ( ) . make_backup ( true ) ;
697
+ config. set_cli ( ) . make_backup ( true ) ;
677
698
}
678
699
if let Some ( color) = self . color {
679
- config. set ( ) . color ( color) ;
700
+ config. set_cli ( ) . color ( color) ;
680
701
}
681
702
if self . print_misformatted_file_names {
682
- config. set ( ) . print_misformatted_file_names ( true ) ;
703
+ config. set_cli ( ) . print_misformatted_file_names ( true ) ;
683
704
}
684
705
685
706
for ( key, val) in self . inline_config {
0 commit comments