From 081f70323ce5b93cb190383cf5eda2a63ffe5962 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Thu, 17 Feb 2022 19:10:45 +0100 Subject: [PATCH] Use configure_me to skip default config files This removes the feature for skipping default config files and replaces it with a configure_me implementation. Closes #217 --- Cargo.lock | 4 ++-- Cargo.toml | 3 +-- internal/config_specification.toml | 1 + src/config.rs | 20 ++++++-------------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15450f7..f4a8962 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -235,9 +235,9 @@ dependencies = [ [[package]] name = "configure_me_codegen" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ddbd860cbff075ceadf4714922a73afbe8bf53d9ed9add6c6b733feeb6f3c7" +checksum = "9aa65df44cc55922b4e22f49939727156a8de25492bf6bd2462a75afc5e155d6" dependencies = [ "cargo_toml", "fmt2io", diff --git a/Cargo.toml b/Cargo.toml index 4d0b0dc..dfaa113 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ build = "build.rs" default = ["metrics"] metrics = ["prometheus", "tiny_http"] metrics_process = ["prometheus/process"] -ignore_default_config_files = [] [package.metadata.configure_me] spec = "internal/config_specification.toml" @@ -51,7 +50,7 @@ default-features = false features = ["zstd", "snappy"] [build-dependencies] -configure_me_codegen = "0.4" +configure_me_codegen = "0.4.2" [dev-dependencies] tempfile = "3.2" diff --git a/internal/config_specification.toml b/internal/config_specification.toml index 85f03a3..021bd49 100644 --- a/internal/config_specification.toml +++ b/internal/config_specification.toml @@ -2,6 +2,7 @@ env_prefix = "ELECTRS" conf_file_param = "conf" conf_dir_param = "conf_dir" +skip_default_conf_files_switch = "skip_default_conf_files" doc = """ An efficient re-implementation of Electrum Server, inspired by ElectrumX, Electrum Personal Server and bitcoincore-indexd. diff --git a/src/config.rs b/src/config.rs index 947fa63..74c39d0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -178,21 +178,13 @@ fn default_daemon_dir() -> PathBuf { } fn default_config_files() -> Vec { - #[cfg(not(feature = "ignore_default_config_files"))] - { - let mut files = vec![OsString::from("electrs.toml")]; // cwd - if let Some(mut path) = home_dir() { - path.extend(&[".electrs", "config.toml"]); - files.push(OsString::from(path)) // home directory - } - files.push(OsString::from("/etc/electrs/config.toml")); // system-wide - files - } - - #[cfg(feature = "ignore_default_config_files")] - { - vec![] + let mut files = vec![OsString::from("electrs.toml")]; // cwd + if let Some(mut path) = home_dir() { + path.extend(&[".electrs", "config.toml"]); + files.push(OsString::from(path)) // home directory } + files.push(OsString::from("/etc/electrs/config.toml")); // system-wide + files } impl Config {