fork_manager/
lib.rs

1use std::fs::File;
2
3mod cli;
4mod config;
5mod error;
6mod template;
7
8pub use cli::{print_completions, Args};
9pub use config::{Change, Config, Fork, Repo, Update, PR};
10pub use error::{Error, Result};
11pub use template::generate;
12
13pub struct ForkManager {
14    args: Args,
15    config: Config,
16}
17
18impl ForkManager {
19    pub async fn new(args: Args) -> Result<Self> {
20        let config_file = File::open(&args.config_file)?;
21        let mut config: Config = serde_yml::from_reader(config_file)?;
22        config.update().await?;
23        Ok(Self { args, config })
24    }
25
26    pub async fn main(&mut self) -> Result<()> {
27        if self.args.dry_run {
28            dbg!(&self.config);
29        } else {
30            generate(self)?;
31        }
32        Ok(())
33    }
34}