@@ -147,7 +147,10 @@ pub fn main() -> Result<()> {
147
147
debugln ! ( "main: {:#?}" , manifest) ;
148
148
149
149
// Gather and parse the tool configuration.
150
- let config = load_config ( & root_dir) ?;
150
+ let config = load_config (
151
+ & root_dir,
152
+ matches ! ( matches. subcommand( ) , Some ( ( "update" , _) ) ) ,
153
+ ) ?;
151
154
debugln ! ( "main: {:#?}" , config) ;
152
155
153
156
// Assemble the session.
@@ -387,7 +390,7 @@ pub fn read_manifest(path: &Path) -> Result<Manifest> {
387
390
}
388
391
389
392
/// Load a configuration by traversing a directory hierarchy upwards.
390
- fn load_config ( from : & Path ) -> Result < Config > {
393
+ fn load_config ( from : & Path , warn_config_loaded : bool ) -> Result < Config > {
391
394
#[ cfg( unix) ]
392
395
use std:: os:: unix:: fs:: MetadataExt ;
393
396
@@ -408,13 +411,13 @@ fn load_config(from: &Path) -> Result<Config> {
408
411
// Step upwards through the path hierarchy.
409
412
for _ in 0 ..100 {
410
413
// Load the optional local configuration.
411
- if let Some ( cfg) = maybe_load_config ( & path. join ( "Bender.local" ) ) ? {
414
+ if let Some ( cfg) = maybe_load_config ( & path. join ( "Bender.local" ) , warn_config_loaded ) ? {
412
415
out = out. merge ( cfg) ;
413
416
}
414
417
415
418
debugln ! ( "load_config: looking in {:?}" , path) ;
416
419
417
- if let Some ( cfg) = maybe_load_config ( & path. join ( ".bender.yml" ) ) ? {
420
+ if let Some ( cfg) = maybe_load_config ( & path. join ( ".bender.yml" ) , warn_config_loaded ) ? {
418
421
out = out. merge ( cfg) ;
419
422
}
420
423
@@ -438,13 +441,13 @@ fn load_config(from: &Path) -> Result<Config> {
438
441
if let Some ( mut home) = dirs:: home_dir ( ) {
439
442
home. push ( ".config" ) ;
440
443
home. push ( "bender.yml" ) ;
441
- if let Some ( cfg) = maybe_load_config ( & home) ? {
444
+ if let Some ( cfg) = maybe_load_config ( & home, warn_config_loaded ) ? {
442
445
out = out. merge ( cfg) ;
443
446
}
444
447
}
445
448
446
449
// Load the global configuration.
447
- if let Some ( cfg) = maybe_load_config ( Path :: new ( "/etc/bender.yml" ) ) ? {
450
+ if let Some ( cfg) = maybe_load_config ( Path :: new ( "/etc/bender.yml" ) , warn_config_loaded ) ? {
448
451
out = out. merge ( cfg) ;
449
452
}
450
453
@@ -472,7 +475,7 @@ fn load_config(from: &Path) -> Result<Config> {
472
475
}
473
476
474
477
/// Load a configuration file if it exists.
475
- fn maybe_load_config ( path : & Path ) -> Result < Option < PartialConfig > > {
478
+ fn maybe_load_config ( path : & Path , warn_config_loaded : bool ) -> Result < Option < PartialConfig > > {
476
479
use std:: fs:: File ;
477
480
debugln ! ( "maybe_load_config: {:?}" , path) ;
478
481
if !path. exists ( ) {
@@ -482,6 +485,9 @@ fn maybe_load_config(path: &Path) -> Result<Option<PartialConfig>> {
482
485
. map_err ( |cause| Error :: chain ( format ! ( "Cannot open config {:?}." , path) , cause) ) ?;
483
486
let partial: PartialConfig = serde_yaml:: from_reader ( file)
484
487
. map_err ( |cause| Error :: chain ( format ! ( "Syntax error in config {:?}." , path) , cause) ) ?;
488
+ if warn_config_loaded {
489
+ warnln ! ( "Using config at {:?} for overrides." , path)
490
+ } ;
485
491
Ok ( Some ( partial. prefix_paths ( path. parent ( ) . unwrap ( ) ) ?) )
486
492
}
487
493
0 commit comments