aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 0365d5bbd55a6f38ef8d92d33305fe85d768f3af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
mod app;
pub mod event;

use std::{error::Error, fs::read_to_string, path::Path};

use app::App;
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() -> Result<(), Box<dyn Error>> {
    let args = Args::parse();
    let path = Path::new(&args.quote_folder);
    let quotes = generate_quotes(&path).unwrap();
    let mut app = App::new(&quotes);

    app.run().await?;
    return Ok(());
}
XMR address: 854DmXNrxULU3ZFJVs4Wc8PFhbq29RhqHhY8W6cdWrtFN3qmooKyyeYPcDzZTNRxphhJ5UzASQfAdEMwSteVqymk28aLhqj