Implement the Default trait for the Argument struct

This commit is contained in:
Anas Elgarhy 2023-02-13 01:11:55 +02:00
parent bd659cd2d9
commit 302c06d1d8
No known key found for this signature in database
GPG Key ID: 0501802A1D496528
3 changed files with 32 additions and 1 deletions

1
Cargo.lock generated
View File

@ -211,6 +211,7 @@ dependencies = [
"lrc",
"notify-rust",
"regex",
"serde",
"temp-file",
"test-context",
"typed-builder",

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
confy = "0.5.1"
serde = "1.0.152"
id3 = "1.6.0"
lrc = { version = "0.1.7", optional = true }
notify-rust = { version = "4.7.0", features = ["images"] }

View File

@ -1,4 +1,5 @@
use clap::Parser;
use serde::{Deserialize, Serialize};
const NOTIFICATION_TIMEOUT: u8 = 5;
const NOTIFICATION_BODY: &str =
@ -8,7 +9,7 @@ const NOTIFICATION_APP_NAME: &str = "C* Music Player";
const DEFAULT_MAX_DEPTH: u8 = 3;
const DEFAULT_INTERVAL_TIME: u64 = 1000; // 1000 ms
#[derive(Parser, Debug)]
#[derive(Parser, Debug, Serialize, Deserialize)]
#[command(author, about, version, long_about = None)]
pub struct Arguments {
/// The notification timeout, in seconds
@ -148,3 +149,31 @@ pub struct Arguments {
#[arg(short = 'o', long)]
pub no_use_external_lyrics: bool,
}
impl Default for Arguments {
fn default() -> Self {
Self {
timeout: NOTIFICATION_TIMEOUT,
persistent: false,
show_track_cover: true,
notification_static_icon: None,
cover_path: None,
lyrics_path: None,
depth: DEFAULT_MAX_DEPTH,
app_name: NOTIFICATION_APP_NAME.to_string(),
summary: NOTIFICATION_SUMMARY.to_string(),
body: NOTIFICATION_BODY.to_string(),
cmus_remote_bin_path: None,
cmus_socket_address: None,
cmus_socket_password: None,
interval: DEFAULT_INTERVAL_TIME,
link: false,
force_use_external_cover: false,
#[cfg(feature = "lyrics")]
force_use_external_lyrics: false,
no_use_external_cover: false,
#[cfg(feature = "lyrics")]
no_use_external_lyrics: false,
}
}
}