mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-27 07:38:51 +00:00
Add packages/cli-rs, an OpenCode client written in Rust on OpenTUI's Rust crates. It is a client only.
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
// 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`)
|