Update account manager config parsing

This commit is contained in:
Paul Hauner
2019-06-09 04:34:56 -04:00
parent 3487b16ce5
commit ab12787610
12 changed files with 66 additions and 96 deletions

View File

@@ -4,7 +4,7 @@ mod run;
use clap::{App, Arg, ArgMatches};
use client::{ClientConfig, Eth2Config};
use eth2_config::{read_from_file, write_to_file};
use eth2_config::{get_data_dir, read_from_file, write_to_file};
use slog::{crit, o, Drain};
use std::fs;
use std::path::PathBuf;
@@ -199,15 +199,3 @@ fn main() {
Err(e) => crit!(logger, "Beacon node failed to start"; "reason" => format!("{:}", e)),
}
}
fn get_data_dir(args: &ArgMatches) -> Result<PathBuf, &'static str> {
if let Some(data_dir) = args.value_of("data_dir") {
Ok(PathBuf::from(data_dir))
} else {
let path = dirs::home_dir()
.ok_or_else(|| "Unable to locate home directory")?
.join(&DEFAULT_DATA_DIR);
fs::create_dir_all(&path).map_err(|_| "Unable to create data_dir")?;
Ok(path)
}
}