From a1c3e7c0473349d862c97824f6560b6b97da2e42 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Fri, 18 Feb 2022 11:58:36 -0800 Subject: [PATCH] Add pullAndRebuildSite command --- src/commands/challenge.rs | 15 +++++++++++++++ src/main.rs | 1 + 2 files changed, 16 insertions(+) diff --git a/src/commands/challenge.rs b/src/commands/challenge.rs index 3c2c629..01ef962 100644 --- a/src/commands/challenge.rs +++ b/src/commands/challenge.rs @@ -122,6 +122,21 @@ async fn rebuildSite(ctx: &Context, msg: &Message) -> CommandResult { Ok(()) } +#[command] +#[owners_only] +#[allow(non_snake_case)] +async fn pullAndRebuildSite(ctx: &Context, msg: &Message) -> CommandResult { + Command::new("git") + .current_dir(get_hugo_path()) + .arg("pull") + .spawn() + .expect("Failed to git pull") + .wait()?; + rebuild_site(); + msg.reply(&ctx.http, "Pulled and started site rebuild process!").await?; + Ok(()) +} + #[command] async fn challenge(ctx: &Context, msg: &Message) -> CommandResult { msg.reply( diff --git a/src/main.rs b/src/main.rs index f4408b9..efd50f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,6 +51,7 @@ impl EventHandler for Handler { hyogai, so, rebuildSite, + pullAndRebuildSite, challenge, submit, images,