From 20a4c4306e85880b48d09744ec7c59a75b511208 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 29 May 2023 19:25:10 +0200 Subject: [PATCH] Look for config files next to input files Previously config files next to an explicit input file could not be picked up, since the `from_root_or_default` functions assumes the input path is a directory. This is the case for all other usages of the function, but in this case we know the input is a file, so we determine the parent directory and look for the config file in that directory. There can't be a folder with the same name as the input file, so it's not possible that we won't pick up any files anymore that we previously did. --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 812366f49..69b5b719e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,7 +84,11 @@ fn load_bindings(input: &Path, matches: &ArgMatches) -> Result // Load any config specified or search in the input directory let mut config = match matches.value_of("config") { Some(c) => Config::from_file(c).unwrap(), - None => Config::from_root_or_default(input), + None => Config::from_root_or_default( + input + .parent() + .expect("All files should have a parent directory"), + ), }; apply_config_overrides(&mut config, matches);