aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-24 11:28:45 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-24 11:45:28 +0200
commit55e8da54a85c817bc6f71a9af43a7f6d813a67b3 (patch)
tree870dea01a562ec3709fd190aa616062705cdb079
parentfix(config): Check for wrong keys in the config file (diff)
downloadyt-55e8da54a85c817bc6f71a9af43a7f6d813a67b3.zip
feat(cli/config): Show the currently active configuration
Diffstat (limited to '')
-rw-r--r--src/cli.rs3
-rw-r--r--src/config/mod.rs7
-rw-r--r--src/main.rs1
-rw-r--r--src/status/mod.rs8
4 files changed, 19 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 3b13bdf..fe89bf7 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -73,6 +73,9 @@ pub enum Command {
/// Show, which videos have been selected to be watched (and their cache status)
Status {},
+ /// Show, the configuration options in effect
+ Config {},
+
/// Perform various tests
Check {
#[command(subcommand)]
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 3d0d0b5..ea40055 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -11,11 +11,13 @@
use std::path::PathBuf;
use bytes::Bytes;
+use serde::Serialize;
mod default;
mod definitions;
pub mod file_system;
+#[derive(Serialize)]
pub struct Config {
pub select: SelectConfig,
pub watch: WatchConfig,
@@ -23,19 +25,24 @@ pub struct Config {
pub download: DownloadConfig,
pub update: UpdateConfig,
}
+#[derive(Serialize)]
pub struct UpdateConfig {
pub max_backlog: u32,
}
+#[derive(Serialize)]
pub struct DownloadConfig {
pub max_cache_size: Bytes,
}
+#[derive(Serialize)]
pub struct SelectConfig {
pub playback_speed: f64,
pub subtitle_langs: String,
}
+#[derive(Serialize)]
pub struct WatchConfig {
pub local_comments_length: usize,
}
+#[derive(Serialize)]
pub struct PathsConfig {
pub download_dir: PathBuf,
pub mpv_config_path: PathBuf,
diff --git a/src/main.rs b/src/main.rs
index 57e711d..2bd7571 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -174,6 +174,7 @@ async fn main() -> Result<()> {
Command::Watch {} => watch::watch(&app).await?,
Command::Status {} => status::show(&app).await?,
+ Command::Config {} => status::config(&app)?,
Command::Database { command } => match command {
CacheCommand::Invalidate { hard } => cache::invalidate(&app, hard).await?,
diff --git a/src/status/mod.rs b/src/status/mod.rs
index 662a391..688ac9a 100644
--- a/src/status/mod.rs
+++ b/src/status/mod.rs
@@ -97,3 +97,11 @@ Dropped Videos: {dropped_videos_len} ({dropped_videos_changing} changing)
Ok(())
}
+
+pub fn config(app: &App) -> Result<()> {
+ let config_str = toml::to_string(&app.config)?;
+
+ print!("{}", config_str);
+
+ Ok(())
+}