From 20c3bbd9a1b5c0d829e5f706153ba009e33e3cbc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Sep 2025 18:27:04 -0700 Subject: [PATCH] docs(schema): add cmd to generate notification schema --- komorebi-client/src/lib.rs | 1 + komorebi/src/core/mod.rs | 2 +- komorebi/src/process_command.rs | 9 +++++++++ komorebic/src/main.rs | 10 +++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 7cb3365a..dd1104a9 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -1,4 +1,5 @@ pub use komorebi::DATA_DIR; +pub use komorebi::Notification; pub use komorebi::core::ApplicationIdentifier; pub use komorebi::core::MoveBehaviour; pub use komorebi::core::OperationBehaviour; diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 55b170d3..4dd7e8d5 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -403,7 +403,7 @@ pub enum SocketMessage { // AddSubscriberPipe(String), // RemoveSubscriberPipe(String), ApplicationSpecificConfigurationSchema, - // NotificationSchema, + NotificationSchema, SocketSchema, StaticConfigSchema, // GenerateStaticConfig, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index af17531b..603cd6f9 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1422,6 +1422,15 @@ impl WindowManager { reply.write_all(schema.as_bytes())?; } } + SocketMessage::NotificationSchema => { + #[cfg(feature = "schemars")] + { + let notification = schemars::schema_for!(Notification); + let schema = serde_json::to_string_pretty(¬ification)?; + + reply.write_all(schema.as_bytes())?; + } + } SocketMessage::SocketSchema => { #[cfg(feature = "schemars")] { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index e8f09229..1b19e894 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1087,7 +1087,7 @@ enum SubCommand { #[clap(alias = "asc-schema")] ApplicationSpecificConfigurationSchema, /// Generate a JSON Schema of subscription notifications - // NotificationSchema, + NotificationSchema, /// Generate a JSON Schema of socket messages SocketSchema, /// Generate a JSON Schema of the static configuration file @@ -1710,6 +1710,14 @@ fn main() -> eyre::Result<()> { println!("{schema}"); } } + SubCommand::NotificationSchema => { + #[cfg(feature = "schemars")] + { + let notification = schemars::schema_for!(komorebi_client::Notification); + let schema = serde_json::to_string_pretty(¬ification)?; + println!("{schema}"); + } + } SubCommand::SocketSchema => { #[cfg(feature = "schemars")] {