Inject version string into manifold

This commit is contained in:
Xyon 2023-08-24 10:04:15 +01:00
parent 58b4caea0d
commit 74a3223032
Signed by: xyon
GPG Key ID: DD18155D6B18078D
3 changed files with 2709 additions and 18 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
/target
*.db
Cargo.lock

2702
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,21 @@
use std::io::stdout;
use clap::ArgMatches;
use diesel::sqlite::Sqlite;
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use poise::serenity_prelude as serenity;
use manifold::config::ManifoldConfig;
use manifold::{ManifoldDatabase, ManifoldDatabasePool};
use poise::serenity_prelude::GatewayIntents;
use crate::built_info;
mod commands;
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
#[tokio::main]
pub async fn run(arguments: ArgMatches) {
let mut client = match manifold::prepare_client(arguments, GatewayIntents::all(), commands::collect_commands()).await {
let git_info: String = built_info::GIT_VERSION.unwrap_or("unknown").to_string();
let version_string = format!("Badgey Bot version {ver} built at {time} from revision {rev}", ver=built_info::PKG_VERSION, time=built_info::BUILT_TIME_UTC, rev=git_info);
let client = match manifold::prepare_client(arguments, GatewayIntents::all(), commands::collect_commands(), version_string).await {
Ok(c) => c,
Err(e) => {
error!("Error preparing client; {:?}", e);
panic!("Error preparing client!");
}
};
client.build().await.unwrap().start().await;
}
fn apply_migrations(conn: &mut impl MigrationHarness<Sqlite>) {
conn.run_pending_migrations(MIGRATIONS)
.expect("An error occurred applying migrations.");
let _ = client.build().await.unwrap().start().await;
}