aboutsummaryrefslogtreecommitdiffstats
path: root/yt/src/version/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'yt/src/version/mod.rs')
-rw-r--r--yt/src/version/mod.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/yt/src/version/mod.rs b/yt/src/version/mod.rs
index 369541e..5e5b9a7 100644
--- a/yt/src/version/mod.rs
+++ b/yt/src/version/mod.rs
@@ -1,6 +1,9 @@
use std::process::Command;
use anyhow::{Context, Result};
+use sqlx::{SqlitePool, sqlite::SqliteConnectOptions};
+
+use crate::{config::Config, storage::migrate::get_version_db};
fn get_cmd_version(cmd: &str) -> Result<String> {
let out = String::from_utf8(
@@ -15,13 +18,31 @@ fn get_cmd_version(cmd: &str) -> Result<String> {
Ok(out.trim().to_owned())
}
-pub fn show() -> Result<()> {
+pub async fn show(config: &Config) -> Result<()> {
+ let db_version = {
+ let options = SqliteConnectOptions::new()
+ .filename(&config.paths.database_path)
+ .optimize_on_close(true, None)
+ .create_if_missing(true);
+
+ let pool = SqlitePool::connect_with(options)
+ .await
+ .context("Failed to connect to database!")?;
+
+ get_version_db(&pool)
+ .await
+ .context("Failed to determine database version")?
+ };
+
+ // TODO(@bpeetz): Use `pyo3`'s build in mechanism instead of executing the python CLI <2025-02-21>
let python_version = get_cmd_version("python")?;
let yt_dlp_version = get_cmd_version("yt-dlp")?;
println!(
"{}: {}
+db version: {db_version}
+
python: {python_version}
yt-dlp: {yt_dlp_version}",
env!("CARGO_PKG_NAME"),