// Writes crates/ui/src/keymap/generated.rs from the TUI's keybind definitions: every name in definition order, // its default as JSON text, and its description. import { TuiKeybind } from "../../../tui/src/config/keybind" const entries = Object.entries(TuiKeybind.Definitions) const lines = [ "// Generated by script/gen/keybinds.ts from packages/tui/src/config/keybind.ts. Do not edit.", "", "/// A configurable keybind name: its default value as JSON text and its description.", "pub struct Definition {", " pub name: &'static str,", " pub default: &'static str,", " pub description: &'static str,", "}", "", `pub const LEADER_DEFAULT: &str = ${JSON.stringify(TuiKeybind.LeaderDefault)};`, "", "pub const DEFINITIONS: &[Definition] = &[", ...entries.map( ([name, item]) => ` Definition { name: ${JSON.stringify(name)}, default: ${JSON.stringify(JSON.stringify(item.default))}, description: ${JSON.stringify(item.description)} },`, ), "];", "", ] const file = new URL("../../crates/ui/src/keymap/generated.rs", import.meta.url).pathname await Bun.write(file, lines.join("\n")) console.log(`keybinds: ${entries.length} definitions`)