aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-23 13:11:09 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-23 13:14:13 +0200
commit94c656ad40a7aae570e5a5fb61ad32632acc6d46 (patch)
tree269614af20caf10d76643c302e0115bd36fd2378 /src/cli.rs
parentrefactor(yt_dlp): Also move the `crates` subdirectory (diff)
downloadyt-94c656ad40a7aae570e5a5fb61ad32632acc6d46.zip
feat(treewide): Use a configuration file
This allows use to avoid duplication of default values in the codebase and obviously also facilitates changing these without having to re-compile.
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/cli.rs b/src/cli.rs
index c567828..05c78de 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -10,14 +10,17 @@
use std::path::PathBuf;
-use anyhow::{bail, Error};
+use anyhow::Context;
use chrono::NaiveDate;
use clap::{ArgAction, Args, Parser, Subcommand};
use url::Url;
use bytes::Bytes;
use crate::{
- constants, select::selection_file::duration::Duration,
+ config::{
+ default::{download, select, update},
+ },
+ select::selection_file::duration::Duration,
storage::video_database::extractor_hash::LazyExtractorHash,
};
@@ -33,10 +36,15 @@ pub struct CliArgs {
#[arg(long="verbose", short = 'v', action = ArgAction::Count)]
pub verbosity: u8,
- /// Set the path to the videos.db. Otherwise use the default location
+ /// Set the path to the videos.db. This overrides the default and the config file.
#[arg(long, short)]
pub db_path: Option<PathBuf>,
+ /// Set the path to the config.toml.
+ /// This overrides the default.
+ #[arg(long, short)]
+ pub config_path: Option<PathBuf>,
+
/// Silence all output
#[arg(long, short = 'q')]
pub quiet: bool,
@@ -52,7 +60,7 @@ pub enum Command {
/// The maximum size the download dir should have. Beware that the value must be given in
/// bytes.
- #[arg(short, long, default_value = "3 GiB", value_parser = byte_parser)]
+ #[arg(short, long, default_value = download::max_cache_size(), value_parser = byte_parser)]
max_cache_size: u64,
},
@@ -88,7 +96,7 @@ pub enum Command {
/// Update the video database
Update {
- #[arg(short, long, default_value = "20")]
+ #[arg(short, long, default_value_t = update::max_backlog() as u32)]
/// The number of videos to updating
max_backlog: u32,
@@ -192,12 +200,11 @@ pub enum SelectCommand {
shared: SharedSelectionCommandArgs,
/// The subtitles to download (e.g. 'en,de,sv')
- #[arg(short = 'l', long, default_value = constants::DEFAULT_SUBTITLE_LANGS)]
+ #[arg(short = 'l', long, default_value = select::subtitle_langs())]
subtitle_langs: String,
/// The speed to set mpv to
- // NOTE: KEEP THIS IN SYNC WITH THE `DEFAULT_MPV_PLAYBACK_SPEED` in `constants.rs` <2024-08-20>
- #[arg(short, long, default_value = "2.7")]
+ #[arg(short, long, default_value_t = select::playback_speed())]
speed: f64,
},