feat(cli): port ghostty +action CLI commands
Ports ZIG/src/cli into ghostty-cli: action detection/dispatch with per-action --help, and the actions help, version, list-actions, list-colors, list-keybinds, list-themes (plain listing plus an interactive ratatui browser mirroring Ghostty's libvaxis UI), show-config, validate-config, edit-config, crash-report (listing), ssh-cache and boo (235 embedded frames). Verified byte-for-byte against the installed Ghostty 1.3.1 for stdout, stderr and exit codes of most actions, incl. tty output in a pty at widths 20-200. Known differences: +list-colors --plain prints all 782 colors (Ghostty truncates at 617 because it never flushes), +version has placeholder build info until build_info::set is wired up. Deferred: list-fonts, show-face (need font discovery integration) and new-window (needs GTK IPC); they return NotYetAvailable for now. Test Plan: - cargo test -p ghostty-cli (86 tests) - cargo run -p ghostty-cli --example cli -- +list-keybinds --plain and diff against `ghostty +list-keybinds --plain`
This commit is contained in:
1 parent
a97ae04f1d
commit
6286e02f07
46 files changed
+7135
-6
No files matched your search
@@ -0,0 +1,85 @@
|
||||
//! Build-time information shown by `+version` (Zig: `build_config`,
|
||||
//! `builtin`, `gtk_version`, `adw_version`).
|
||||
//!
|
||||
//! TODO(integration): the root crate / apprt-gtk should call [`set`] with the
|
||||
//! real GTK and libadwaita versions (the Zig code queries them at runtime).
|
||||
|
||||
use std::sync::OnceLock;
|
||||
|
||||
/// A `major.minor.micro` version (Zig: `gtk_version.zig` / `adw_version.zig`).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Version {
|
||||
pub major: u32,
|
||||
pub minor: u32,
|
||||
pub micro: u32,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Version {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}.{}.{}", self.major, self.minor, self.micro)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BuildInfo {
|
||||
/// `build_config.version_string`.
|
||||
pub version_string: String,
|
||||
/// `build_config.version.build` (the git commit hash), if known.
|
||||
pub commit: Option<String>,
|
||||
/// `build_config.release_channel` tag name (`stable` / `tip`).
|
||||
pub release_channel: String,
|
||||
/// `{}` of `builtin.mode` (`.Debug`, `.ReleaseFast`, ...).
|
||||
pub build_mode: String,
|
||||
/// `{}` of `build_config.app_runtime`.
|
||||
pub app_runtime: String,
|
||||
/// `{}` of `build_config.font_backend`.
|
||||
pub font_backend: String,
|
||||
/// `{}` of `renderer.Renderer`.
|
||||
pub renderer: String,
|
||||
pub gtk_build: Option<Version>,
|
||||
pub gtk_runtime: Option<Version>,
|
||||
pub adw_build: Option<Version>,
|
||||
pub adw_runtime: Option<Version>,
|
||||
/// `build_options.x11`.
|
||||
pub x11: bool,
|
||||
/// `build_options.wayland`.
|
||||
pub wayland: bool,
|
||||
}
|
||||
|
||||
impl Default for BuildInfo {
|
||||
fn default() -> Self {
|
||||
BuildInfo {
|
||||
version_string: "1.3.1".to_string(),
|
||||
commit: None,
|
||||
release_channel: "stable".to_string(),
|
||||
build_mode: if cfg!(debug_assertions) {
|
||||
".Debug"
|
||||
} else {
|
||||
".ReleaseFast"
|
||||
}
|
||||
.to_string(),
|
||||
app_runtime: ".gtk".to_string(),
|
||||
font_backend: ".fontconfig_freetype".to_string(),
|
||||
renderer: "renderer.generic.Renderer(renderer.OpenGL)".to_string(),
|
||||
gtk_build: None,
|
||||
gtk_runtime: None,
|
||||
adw_build: None,
|
||||
adw_runtime: None,
|
||||
x11: true,
|
||||
wayland: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INFO: OnceLock<BuildInfo> = OnceLock::new();
|
||||
|
||||
/// Install the build info. Returns false if it was already set.
|
||||
pub fn set(info: BuildInfo) -> bool {
|
||||
INFO.set(info).is_ok()
|
||||
}
|
||||
|
||||
/// The installed build info, or the defaults.
|
||||
#[must_use]
|
||||
pub fn get() -> BuildInfo {
|
||||
INFO.get().cloned().unwrap_or_default()
|
||||
}
|
||||
Reference in new issue
Block a user