From df38ea5413d9e1740abd8bba43b9aba1272b0e0d Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Thu, 6 Mar 2025 17:44:52 -0700 Subject: [PATCH] feat: Write built in themes to the themes file on first run so users can define custom themes --- README.md | 5 + proc_macros/validate_theme_derive/src/lib.rs | 80 +++--- src/builtin_themes.rs | 92 +++++++ src/builtin_themes_tests.rs | 96 +++++++ src/main.rs | 21 +- src/ui/theme.rs | 38 ++- src/ui/theme_tests.rs | 253 +++++++++++++++++- src/utils.rs | 4 +- ...validate_theme_derive_integration_tests.rs | 42 +-- themes/README.md | 92 +++++++ themes/default/README.md | 9 + themes/default/manual_episode_search.png | Bin 0 -> 348305 bytes themes/default/radarr_system.png | Bin 0 -> 350408 bytes themes/default/sonarr_library.png | Bin 0 -> 222079 bytes themes/default/themes.yml | 37 +++ themes/dracula/README.md | 9 + themes/dracula/manual_episode_search.png | Bin 0 -> 387471 bytes themes/dracula/radarr_system.png | Bin 0 -> 374836 bytes themes/dracula/sonarr_library.png | Bin 0 -> 262882 bytes themes/dracula/themes.yml | 29 ++ themes/watermelon-dark/README.md | 9 + .../watermelon-dark/manual_episode_search.png | Bin 0 -> 385131 bytes themes/watermelon-dark/radarr_system.png | Bin 0 -> 375690 bytes themes/watermelon-dark/sonarr_library.png | Bin 0 -> 260919 bytes themes/watermelon-dark/themes.yml | 16 ++ 25 files changed, 758 insertions(+), 74 deletions(-) create mode 100644 src/builtin_themes.rs create mode 100644 src/builtin_themes_tests.rs create mode 100644 themes/README.md create mode 100644 themes/default/README.md create mode 100644 themes/default/manual_episode_search.png create mode 100644 themes/default/radarr_system.png create mode 100644 themes/default/sonarr_library.png create mode 100644 themes/default/themes.yml create mode 100644 themes/dracula/README.md create mode 100644 themes/dracula/manual_episode_search.png create mode 100644 themes/dracula/radarr_system.png create mode 100644 themes/dracula/sonarr_library.png create mode 100644 themes/dracula/themes.yml create mode 100644 themes/watermelon-dark/README.md create mode 100644 themes/watermelon-dark/manual_episode_search.png create mode 100644 themes/watermelon-dark/radarr_system.png create mode 100644 themes/watermelon-dark/sonarr_library.png create mode 100644 themes/watermelon-dark/themes.yml diff --git a/README.md b/README.md index 95f9cb1..59a862a 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,9 @@ Key: - [ ] Support for Tautulli +### Themes +Managarr ships with a few themes out of the box. See the [Themes README](themes/README.md) page for more information. + ### The Managarr CLI Managarr can be used in one of two ways: As a TUI, or as a CLI for managing your Servarrs. @@ -315,6 +318,7 @@ managarr --config-file /path/to/config.yml ### Example Configuration: ```yaml +theme: default radarr: - host: 192.168.0.78 port: 7878 @@ -357,6 +361,7 @@ tautulli: ### Example Multi-Instance Configuration: ```yaml +theme: default radarr: - host: 192.168.0.78 # No name specified, so this instance's name will default to 'Radarr 1' port: 7878 diff --git a/proc_macros/validate_theme_derive/src/lib.rs b/proc_macros/validate_theme_derive/src/lib.rs index 686beea..6a6ca27 100644 --- a/proc_macros/validate_theme_derive/src/lib.rs +++ b/proc_macros/validate_theme_derive/src/lib.rs @@ -1,18 +1,18 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, Data, DeriveInput, Fields}; +use syn::{Data, DeriveInput, Fields, parse_macro_input}; /// Derive macro for generating a `validate` method for a Theme struct. /// The `validate` method ensures that all values with the `validate` attribute are not `None`. /// Otherwise, an error message it output to both the log file and stdout and the program exits. -/// +/// /// # Example -/// +/// /// Valid themes pass through the program transitively without any messages being output. -/// +/// /// ``` /// use validate_theme_derive::ValidateTheme; -/// +/// /// #[derive(ValidateTheme, Default)] /// struct Theme { /// pub name: String, @@ -22,22 +22,22 @@ use syn::{parse_macro_input, Data, DeriveInput, Fields}; /// pub bad: Option