use clap::{Parser, ValueEnum};
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum PopupPosition {
TopRight,
TopLeft,
BottomRight,
BottomLeft,
}
#[derive(Parser, Debug, Clone)]
#[command(name = "nwg-notifications", version, about)]
pub struct NotificationConfig {
#[arg(long, value_enum, default_value_t = PopupPosition::TopRight)]
pub popup_position: PopupPosition,
#[arg(long, default_value_t = 7000)]
pub popup_timeout: u64,
#[arg(long, default_value_t = 5)]
pub max_popups: usize,
#[arg(long, default_value_t = 200)]
pub max_history: usize,
#[arg(long)]
pub dnd: bool,
#[arg(long)]
pub persist: bool,
#[arg(long)]
pub debug: bool,
#[arg(long, value_enum)]
pub wm: Option<nwg_common::compositor::WmOverride>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn defaults() {
let config = NotificationConfig::parse_from(["test"]);
assert_eq!(config.popup_position, PopupPosition::TopRight);
assert_eq!(config.popup_timeout, 7000);
assert_eq!(config.max_history, 200);
assert!(!config.dnd);
}
#[test]
fn dnd_flag() {
let config = NotificationConfig::parse_from(["test", "--dnd"]);
assert!(config.dnd);
}
#[test]
fn wm_flag_hyprland() {
let config = NotificationConfig::parse_from(["test", "--wm", "hyprland"]);
assert_eq!(
config.wm,
Some(nwg_common::compositor::WmOverride::Hyprland)
);
}
#[test]
fn wm_flag_uwsm() {
let config = NotificationConfig::parse_from(["test", "--wm", "uwsm"]);
assert_eq!(config.wm, Some(nwg_common::compositor::WmOverride::Uwsm));
}
#[test]
fn wm_flag_default_none() {
let config = NotificationConfig::parse_from(["test"]);
assert_eq!(config.wm, None);
}
}