add version command
This commit is contained in:
15
build.rs
Normal file
15
build.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// get
|
||||||
|
let output = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output()
|
||||||
|
.expect("git rev-parse HEAD failed");
|
||||||
|
let hash = String::from_utf8(output.stdout).expect("not UTF-8 output");
|
||||||
|
|
||||||
|
let output = Command::new("git").args(&["rev-parse", "--abbrev-ref", "HEAD"]).output()
|
||||||
|
.expect("git rev-parse HEAD failed");
|
||||||
|
let branch = String::from_utf8(output.stdout).expect("not UTF-8 output");
|
||||||
|
|
||||||
|
println!("cargo:rustc-env=GIT_HASH={}", hash);
|
||||||
|
println!("cargo:rustc-env=GIT_BRANCH={}", branch);
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ mod gambling;
|
|||||||
mod eval;
|
mod eval;
|
||||||
pub mod self_roles;
|
pub mod self_roles;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
mod version;
|
||||||
|
|
||||||
use crate::common::{Data, Error, Context};
|
use crate::common::{Data, Error, Context};
|
||||||
|
|
||||||
@@ -35,5 +36,6 @@ pub fn commands() -> Vec<Command<Data, Error>> {
|
|||||||
eval::eval(),
|
eval::eval(),
|
||||||
self_roles::role(),
|
self_roles::role(),
|
||||||
settings::setting(),
|
settings::setting(),
|
||||||
|
version::version(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/commands/version.rs
Normal file
8
src/commands/version.rs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
use crate::common::{Context, Error};
|
||||||
|
|
||||||
|
/// Tells you the current version of BigBirb
|
||||||
|
#[poise::command(slash_command, prefix_command)]
|
||||||
|
pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
ctx.reply(format!("version {} ({}/{})", env!("CARGO_PKG_VERSION"), env!("GIT_BRANCH"), env!("GIT_HASH"))).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user