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
use crate::prelude::*;

mod cluster;
mod scan;
mod work_gender;

/// GoodReads processing commands.
#[derive(Args, Debug)]
pub struct Goodreads {
    #[command(subcommand)]
    command: GRCmd,
}

#[derive(clap::Subcommand, Debug)]
enum GRCmd {
    /// Scan GoodReads data.
    Scan {
        #[command(subcommand)]
        data: scan::GRScan,
    },
    /// Cluster GoodReads intearaction data.
    ClusterInteractions(cluster::CICommand),
    /// Compute GoodReads work genders.
    WorkGender,
}

impl Command for Goodreads {
    fn exec(&self) -> Result<()> {
        match &self.command {
            GRCmd::Scan { data } => {
                data.exec()?;
            }
            GRCmd::ClusterInteractions(opts) => {
                opts.exec()?;
            }
            GRCmd::WorkGender => {
                work_gender::link_work_genders()?;
            }
        }

        Ok(())
    }
}