make standard config file path in home-directory work properly
This commit is contained in:
+4
-3
@@ -30,7 +30,8 @@ struct DbData{
|
||||
|
||||
//fn main() {
|
||||
fn main () {
|
||||
let mut config_file_path = "~/.isolated-switches/config.json";
|
||||
let home_dir = env::home_dir().expect("Could not determine home directory");
|
||||
let mut config_file_path: &str = &(home_dir.to_string_lossy() + "/.isolated-switches/config.json");
|
||||
|
||||
// read and parse command line parameters
|
||||
let args: Vec<String> = env::args().collect();
|
||||
@@ -76,8 +77,8 @@ fn main () {
|
||||
|
||||
// read and parse configuration file
|
||||
fn read_config(config_file_path: &str) -> Config {
|
||||
let config_file = File::open(&config_file_path)
|
||||
.expect("Could not read config file");
|
||||
let config_file = File::open(config_file_path)
|
||||
.expect(&("Could not read config file ".to_owned() + config_file_path ));
|
||||
let config: Config = serde_json::from_reader(config_file)
|
||||
.expect("file should be proper JSON");
|
||||
config
|
||||
|
||||
Reference in New Issue
Block a user