From 1bee9f225ddc49140c1920ea3ef89973f9fafb99 Mon Sep 17 00:00:00 2001 From: Del Date: Wed, 12 May 2021 20:21:14 +0000 Subject: [PATCH] Add basic config fetching --- .gitignore | 2 ++ Cargo.lock | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 11 ++++++ src/main.rs | 29 ++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..461c0c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +*.*~ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..cdca3fa --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,97 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + +[[package]] +name = "proc-macro2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "schloop" +version = "0.1.0" +dependencies = [ + "serde", + "serde_yaml", +] + +[[package]] +name = "serde" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_yaml" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + +[[package]] +name = "syn" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..ce4d9da --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "schloop" +version = "0.1.0" +authors = ["del"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { version = "1.0", features = ["derive"] } +serde_yaml = "0.8" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..ab81fd3 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; +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"); + + + let input_paths = fs::read_dir(conf.input_path).unwrap(); + + for path in input_paths { + println!("{}", path.unwrap().path().display()) + } +}