config loading

This commit is contained in:
mii
2024-02-13 20:52:58 +09:00
parent d40e6e3b75
commit 1f6b7b527f
2 changed files with 47 additions and 26 deletions

View File

@ -1,3 +1,5 @@
use std::io::Read;
use crate::args::Run;
fn reshape_audio_data<T>(input: &[T], channels: usize) -> Vec<Vec<T>>
@ -28,6 +30,25 @@ where
output
}
pub fn run(args: Run) {
pub fn run(run: Run) {
let config = std::path::Path::new(&run.config);
}
if !config.exists() {
eprintln!("Config file does not exists.");
return;
}
let mut buf = String::default();
let mut config = if let Ok(config) = std::fs::File::open(&config) {
config
} else {
eprintln!("Cannot open config file.");
return;
};
config.read_to_string(&mut buf).unwrap();
let config: crate::config::Config = serde_yaml::from_str(&buf).unwrap();
println!("{:?}", config);
}