refactor(bar): print --schema through the platform view

Both bars now print `schema.bar.json` as the view of the generated union
schema (komorebi_bar_core::schema::generated_text): Windows through the
Windows view (the identity), macOS through the macOS view. The sources of
both bars are still separate, so the generated text is what it was and the
macOS changes set what is already there (they are idempotent); this is the
switch that lets the next revisions move code that differs only in schema
text into the core in the Windows spelling.

Verified: out-of-tree schema harness (S/bar2/regen.sh, real sources, bins
updated to call generated_text): macOS byte-identical to
komorebi-for-mac/schema.bar.json (3,774 lines), Windows byte-identical to
schema.bar.json (9,091 lines). Native bar-core tests 3+5 passed, Windows
clippy -D warnings clean, macOS fake-CC check 0 errors. The binaries were
not run (cannot on Linux).
This commit is contained in:
LGUG2Z committed 2026-10-31 10:09:33 -07:00
1 parent 280eea6fec
commit 352cda3be3
3 files changed
+20 -8

No files matched your search

@@ -118,3 +118,11 @@ fn collect_refs(value: &Value, found: &mut Vec<String>) {
_ => {}
}
}
/// The text `--schema` prints for the bar configuration type `T`, as `platform` checks it in.
#[cfg(feature = "schemars")]
#[must_use]
pub fn generated_text<T: schemars::JsonSchema>(platform: SchemaPlatform) -> String {
let union = serde_json::to_value(schemars::schema_for!(T)).expect("a schema is JSON");
view_text(union, platform)
}
+6 -4
View File
@@ -106,10 +106,12 @@ fn main() -> color_eyre::Result<()> {
#[cfg(feature = "schemars")]
if opts.schema {
let bar_config = schemars::schema_for!(KomobarConfig);
let schema = serde_json::to_string_pretty(&bar_config)?;
println!("{schema}");
print!(
"{}",
komorebi_bar_core::schema::generated_text::<KomobarConfig>(
komorebi_bar_core::schema::SchemaPlatform::Windows
)
);
std::process::exit(0);
}
+6 -4
View File
@@ -71,10 +71,12 @@ fn main() -> eyre::Result<()> {
#[cfg(feature = "schemars")]
if opts.schema {
let bar_config = schemars::schema_for!(KomobarConfig);
let schema = serde_json::to_string_pretty(&bar_config)?;
println!("{schema}");
print!(
"{}",
komorebi_bar_core::schema::generated_text::<KomobarConfig>(
komorebi_bar_core::schema::SchemaPlatform::MacOs
)
);
std::process::exit(0);
}