From 2568d96ac3f7a772bf96519bfd8a82557946e317 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Fri, 16 Feb 2024 18:58:20 +0100 Subject: [PATCH] module structure --- src/config/mod.rs | 4 ++-- src/lib.rs | 3 +++ src/main.rs | 8 +++++--- src/publish/mod.rs | 4 ++++ src/release/mod.rs | 5 +++++ src/serverapi/mod.rs | 0 6 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 src/publish/mod.rs create mode 100644 src/release/mod.rs create mode 100644 src/serverapi/mod.rs diff --git a/src/config/mod.rs b/src/config/mod.rs index 48be007..6943768 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -156,7 +156,7 @@ impl Debug for Config { } impl Config { - pub fn load(cli: Cli) -> Result { + pub fn load(cli: &Cli) -> Result { let repo = match git2::Repository::open_from_env() { Ok(repo) => repo, Err(_err) => { @@ -197,7 +197,7 @@ impl Config { yaml, repo, path, - cli, + cli: cli.clone(), }) } } diff --git a/src/lib.rs b/src/lib.rs index 46700fe..9411176 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ pub mod changelog; +pub mod publish; +pub mod serverapi; +pub mod release; pub mod config; pub mod error; diff --git a/src/main.rs b/src/main.rs index 20512d5..038ff95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,23 +4,25 @@ use autocrate::{ cli::{Cli, Commands}, Config, }, + release::release, + publish::publish, error::*, }; #[tokio::main] async fn main() -> Result<()> { let cli = Cli::cli_parse(); - let cfg = Config::load(cli.clone())?; + let cfg = Config::load(&cli)?; match cli.command { Commands::Changelog { .. } => { println!("{}", Changelog::build(&cfg)?); } Commands::Release { .. } => { - todo!() + release(&cfg)?; } Commands::Publish { .. } => { - todo!() + publish(&cfg)?; } }; Ok(()) diff --git a/src/publish/mod.rs b/src/publish/mod.rs new file mode 100644 index 0000000..22ec176 --- /dev/null +++ b/src/publish/mod.rs @@ -0,0 +1,4 @@ +use crate::{config::Config, error::*}; +pub fn publish(cfg: &Config) -> Result<()> { + todo!() +} diff --git a/src/release/mod.rs b/src/release/mod.rs new file mode 100644 index 0000000..35216ec --- /dev/null +++ b/src/release/mod.rs @@ -0,0 +1,5 @@ +use crate::{config::Config, error::*}; + +pub fn release(cfg: &Config) -> Result<()> { + todo!() +} diff --git a/src/serverapi/mod.rs b/src/serverapi/mod.rs new file mode 100644 index 0000000..e69de29