diff options
| author | Mroik <mroik@delayed.space> | 2025-01-27 07:50:20 +0100 |
|---|---|---|
| committer | Mroik <mroik@delayed.space> | 2025-02-01 19:32:57 +0100 |
| commit | 318a19429a34ff48dbcc1894373fc6430435e36f (patch) | |
| tree | 1ddff90083405e057d174b14ea3a39444c8adbb9 /src/main.rs | |
First commit
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..ba5277e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,51 @@ +mod app; +pub mod event; + +use std::{error::Error, fs::read_to_string, path::Path}; + +use clap::Parser; + +#[derive(Parser)] +struct Args { + #[arg(short, long)] + quote_folder: String, +} + +fn generate_quotes(path: &Path) -> Result<Vec<Vec<String>>, Box<dyn Error>> { + let mut ris = Vec::new(); + if path.is_file() { + ris.push( + read_to_string(path)? + .trim() + .split_whitespace() + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()) + .collect(), + ); + } else { + for f in path.read_dir()? { + if f.is_err() { + continue; + } + let v = f.unwrap().path(); + if v.is_file() { + ris.push( + read_to_string(v)? + .trim() + .split_whitespace() + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()) + .collect(), + ); + } + } + } + return Ok(ris); +} + +#[tokio::main] +async fn main() { + let args = Args::parse(); + let path = Path::new(&args.quote_folder); + let quotes = generate_quotes(&path).unwrap(); +} |
