@@ -147,7 +147,10 @@ pub fn main() -> Result<()> {
147147 debugln ! ( "main: {:#?}" , manifest) ;
148148
149149 // 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+ ) ?;
151154 debugln ! ( "main: {:#?}" , config) ;
152155
153156 // Assemble the session.
@@ -387,7 +390,7 @@ pub fn read_manifest(path: &Path) -> Result<Manifest> {
387390}
388391
389392/// 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 > {
391394 #[ cfg( unix) ]
392395 use std:: os:: unix:: fs:: MetadataExt ;
393396
@@ -408,13 +411,13 @@ fn load_config(from: &Path) -> Result<Config> {
408411 // Step upwards through the path hierarchy.
409412 for _ in 0 ..100 {
410413 // 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 ) ? {
412415 out = out. merge ( cfg) ;
413416 }
414417
415418 debugln ! ( "load_config: looking in {:?}" , path) ;
416419
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 ) ? {
418421 out = out. merge ( cfg) ;
419422 }
420423
@@ -438,13 +441,13 @@ fn load_config(from: &Path) -> Result<Config> {
438441 if let Some ( mut home) = dirs:: home_dir ( ) {
439442 home. push ( ".config" ) ;
440443 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 ) ? {
442445 out = out. merge ( cfg) ;
443446 }
444447 }
445448
446449 // 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 ) ? {
448451 out = out. merge ( cfg) ;
449452 }
450453
@@ -472,7 +475,7 @@ fn load_config(from: &Path) -> Result<Config> {
472475}
473476
474477/// 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 > > {
476479 use std:: fs:: File ;
477480 debugln ! ( "maybe_load_config: {:?}" , path) ;
478481 if !path. exists ( ) {
@@ -482,6 +485,9 @@ fn maybe_load_config(path: &Path) -> Result<Option<PartialConfig>> {
482485 . map_err ( |cause| Error :: chain ( format ! ( "Cannot open config {:?}." , path) , cause) ) ?;
483486 let partial: PartialConfig = serde_yaml:: from_reader ( file)
484487 . 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+ } ;
485491 Ok ( Some ( partial. prefix_paths ( path. parent ( ) . unwrap ( ) ) ?) )
486492}
487493
0 commit comments