schloop/src/main.rs

40 lines
970 B
Rust

use serde::{Deserialize, Serialize};
use std::error::Error;
use std::{env, fs};
#[derive(Debug, Serialize, Deserialize)]
struct Config {
input_path: String,
gemini_output_path: String,
html_output_path: String,
}
fn main() {
let conf_path = env::args()
.nth(1)
.expect("first argument must be config file path");
println!("Loading config file");
let conf_str = fs::read_to_string(&conf_path)
.expect("failed to read config file {conf_path}");
let conf : Config = serde_yaml::from_str(&conf_str)
.expect("invalid config format");
load_paths(&conf.input_path).unwrap();
}
fn load_paths(root_dir : &str) -> Result<(), Box<dyn Error>> {
let entries = fs::read_dir(root_dir)?;
for entry in entries {
let entry = entry?;
let meta = entry.metadata()?;
if meta.is_file() {
println!("{}", entry.path().display());
}
}
Ok(())
}