diff --git a/Cargo.lock b/Cargo.lock index 1ee6861..8cc8d29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1391,6 +1391,7 @@ dependencies = [ "tokio", "tokio-util", "urlencoding", + "validate_theme_derive", "veil", ] @@ -2780,6 +2781,15 @@ dependencies = [ "getrandom 0.3.1", ] +[[package]] +name = "validate_theme_derive" +version = "0.1.0" +dependencies = [ + "log", + "quote", + "syn 2.0.99", +] + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index a6442ed..2f64107 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ rust-version = "1.85.0" exclude = [".github", "CONTRIBUTING.md", "*.log", "tags"] [workspace] -members = ["proc_macros/enum_display_style_derive"] +members = ["proc_macros/enum_display_style_derive", "proc_macros/validate_theme_derive"] [dependencies] anyhow = "1.0.68" @@ -63,6 +63,7 @@ deunicode = "1.6.0" paste = "1.0.15" openssl = { version = "0.10.70", features = ["vendored"] } veil = "0.2.0" +validate_theme_derive = { path = "proc_macros/validate_theme_derive" } enum_display_style_derive = { path = "proc_macros/enum_display_style_derive" } [dev-dependencies] diff --git a/README.md b/README.md index 95f9cb1..ddc6eeb 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,16 @@ Key: - [ ] Support for Tautulli +### Themes +Managarr ships with a few themes out of the box. Here's a few examples: + +![default](themes/default/manual_episode_search.png) +![dracula](themes/dracula/manual_episode_search.png) +![watermelon-dark](themes/watermelon-dark/manual_episode_search.png) + +You can also create your own custom themes as well. To learn more about what themes are built-in to Managarr and how +to create your own custom themes, check out the [Themes README](themes/README.md). + ### The Managarr CLI Managarr can be used in one of two ways: As a TUI, or as a CLI for managing your Servarrs. @@ -218,7 +228,7 @@ To see all available commands, simply run `managarr --help`: ```shell $ managarr --help -managarr 0.5.0 +managarr 0.5.1 Alex Clarke A TUI and CLI to manage your Servarrs @@ -235,6 +245,8 @@ Commands: Options: --disable-spinner Disable the spinner (can sometimes make parsing output challenging) [env: MANAGARR_DISABLE_SPINNER=] --config-file The Managarr configuration file to use [env: MANAGARR_CONFIG_FILE=] + --themes-file The Managarr themes file to use [env: MANAGARR_THEMES_FILE=] + --theme The name of the Managarr theme to use [env: MANAGARR_THEME=] --servarr-name For multi-instance configurations, you need to specify the name of the instance configuration that you want to use. This is useful when you have multiple instances of the same Servarr defined in your config file. By default, if left empty, the first configured Servarr instance listed in the config file will be used. @@ -315,6 +327,7 @@ managarr --config-file /path/to/config.yml ### Example Configuration: ```yaml +theme: default radarr: - host: 192.168.0.78 port: 7878 @@ -357,6 +370,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/enum_display_style_derive/src/lib.rs b/proc_macros/enum_display_style_derive/src/lib.rs index 05d2f5e..3e2c941 100644 --- a/proc_macros/enum_display_style_derive/src/lib.rs +++ b/proc_macros/enum_display_style_derive/src/lib.rs @@ -4,7 +4,8 @@ use crate::macro_models::DisplayStyleArgs; use darling::FromVariant; use quote::quote; use syn::{Data, DeriveInput, parse_macro_input}; -/// Derive macro for the EnumDisplayStyle trait. + +/// Derive macro for generating a `to_display_str` method for an enum. /// /// # Example /// @@ -15,13 +16,12 @@ use syn::{Data, DeriveInput, parse_macro_input}; /// /// #[derive(EnumDisplayStyle)] /// enum Weekend { -/// Saturday, -/// Sunday, +/// Saturday, +/// Sunday, /// } /// /// assert_eq!(Weekend::Saturday.to_display_str(), "Saturday"); /// assert_eq!(Weekend::Sunday.to_display_str(), "Sunday"); -/// /// ``` /// /// Using custom values for the display style: @@ -31,10 +31,10 @@ use syn::{Data, DeriveInput, parse_macro_input}; /// /// #[derive(EnumDisplayStyle)] /// enum MonitorStatus { -/// #[display_style(name = "Monitor Transactions")] -/// Active, -/// #[display_style(name = "Don't Monitor Transactions")] -/// None, +/// #[display_style(name = "Monitor Transactions")] +/// Active, +/// #[display_style(name = "Don't Monitor Transactions")] +/// None, /// } /// /// assert_eq!(MonitorStatus::Active.to_display_str(), "Monitor Transactions"); diff --git a/proc_macros/validate_theme_derive/Cargo.toml b/proc_macros/validate_theme_derive/Cargo.toml new file mode 100644 index 0000000..084f7a4 --- /dev/null +++ b/proc_macros/validate_theme_derive/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "validate_theme_derive" +version = "0.1.0" +edition = "2024" + +[lib] +proc-macro = true + +[dependencies] +quote = "1.0.39" +syn = "2.0.99" + +[dev-dependencies] +log = "0.4.17" diff --git a/proc_macros/validate_theme_derive/src/lib.rs b/proc_macros/validate_theme_derive/src/lib.rs new file mode 100644 index 0000000..7ed9b0a --- /dev/null +++ b/proc_macros/validate_theme_derive/src/lib.rs @@ -0,0 +1,106 @@ +use proc_macro::TokenStream; +use quote::quote; +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, +/// #[validate] +/// pub good: Option