Skip to content

Commit

Permalink
Load config from default path if cmd arg is not provided (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
justprosh authored Oct 28, 2021
1 parent 527e26e commit 7b7049c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/server-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ use std::time::Duration;

const CONFIG_VERSION: usize = 1;

pub fn default_config_path() -> PathBuf {
default_base_dir().join("Config.toml")
}

pub fn default_tcp_port() -> u16 {
7777
}
Expand Down
4 changes: 3 additions & 1 deletion crates/server-config/src/resolved_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

use crate::defaults::default_config_path;
use crate::dir_config::{ResolvedDirConfig, UnresolvedDirConfig};
use crate::node_config::NodeConfig;
use crate::ListenConfig;
Expand Down Expand Up @@ -237,8 +238,9 @@ fn insert_args_to_config(
// TODO: avoid depending on ArgMatches
pub fn load_config(arguments: ArgMatches) -> eyre::Result<ResolvedConfig> {
let config_file = arguments.value_of(CONFIG_FILE).map(Into::into);
let config_file = config_file.unwrap_or(default_config_path());

let config_bytes = if let Some(config_file) = config_file {
let config_bytes = if config_file.is_file() {
let config_file = to_abs_path(config_file);

log::info!("Loading config from {:?}", config_file);
Expand Down

0 comments on commit 7b7049c

Please sign in to comment.