termusiclib/
lib.rs

1#![forbid(unsafe_code)]
2#![recursion_limit = "2048"]
3#![warn(clippy::all, clippy::correctness)]
4#![warn(rust_2018_idioms)]
5#![warn(clippy::pedantic)]
6// TODO: work to remove the following lints
7#![allow(clippy::missing_errors_doc)]
8
9pub mod config;
10pub mod ids;
11pub mod invidious;
12pub mod library_db;
13pub mod player;
14pub mod playlist;
15pub mod podcast;
16pub mod songtag;
17pub mod taskpool;
18pub mod track;
19pub mod types;
20pub mod ueberzug;
21pub mod utils;
22pub mod xywh;
23
24pub const VERSION: &str = env!("CARGO_PKG_VERSION");
25
26use include_dir::{include_dir, Dir};
27pub static THEME_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/themes");
28
29#[macro_use]
30extern crate log;
31
32#[cfg(test)]
33mod tests {
34    use std::{ffi::OsStr, path::PathBuf};
35
36    use crate::config::v2::tui::theme::ThemeColors;
37
38    /// Test that all themes in /lib/themes/ can be loaded
39    #[test]
40    fn should_parse_all_themes() {
41        let cargo_manifest_dir = env!("CARGO_MANIFEST_DIR");
42        let path = PathBuf::from(format!("{cargo_manifest_dir}/themes/"));
43        for entry in path.read_dir().unwrap() {
44            let entry = entry.unwrap();
45            let entry_path = entry.path();
46
47            if entry_path.extension() != Some(OsStr::new("yml")) {
48                continue;
49            }
50
51            println!(
52                "Theme: {}",
53                entry_path.file_name().unwrap().to_string_lossy()
54            );
55
56            let actual_theme = ThemeColors::from_yaml_file(&entry_path).unwrap();
57
58            assert!(actual_theme.file_name.is_some_and(|v| !v.is_empty()));
59        }
60    }
61}