Adds header parsing with basic arguments
This commit is contained in:
48
src/main.rs
48
src/main.rs
@@ -1,3 +1,47 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use std::{env::{self}, io::Error, path::Path};
|
||||
use std::fs;
|
||||
|
||||
pub mod headproc; // The HEAder PROCessing
|
||||
|
||||
/// Use for handling possible formats of the WFDB data
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum SignalFormat {
|
||||
Format16 = 16,
|
||||
Format212 = 212,
|
||||
Unimpl = 0
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error>{
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() <= 1 || args.contains(&"help".to_string()) {
|
||||
help();
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let filepath = Path::new(&args[1]);
|
||||
if !filepath.is_file() {
|
||||
println!("Path argument provided is not a valid file");
|
||||
return Ok(());
|
||||
}
|
||||
if filepath.extension().unwrap() != "hea" {
|
||||
println!("File provided is not a .hea file");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let hea_file_result = fs::read_to_string(filepath);
|
||||
match hea_file_result {
|
||||
Ok(file_data) => {
|
||||
let header = headproc::parse_header(file_data.as_str());
|
||||
dbg!(header);
|
||||
}
|
||||
Err(e) => return Err(e)
|
||||
}
|
||||
println!("Hello, world!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn help() {
|
||||
println!("Conversion of WFDB files to a more human readable format. By default to a CSV.");
|
||||
println!("\nUse in the format \"wfdb_corrosion (.hea filename)\"")
|
||||
}
|
||||
Reference in New Issue
Block a user