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
5462bd8e3e
commit
f2c4b40062
46 files changed
+7135
-6
No files matched your search
@@ -0,0 +1,48 @@
|
||||
//! The error type returned by CLI actions.
|
||||
|
||||
use ghostty_config::cli_args::ArgError;
|
||||
|
||||
/// The name used by [`ArgError::Other`] to signal that `--help`/`-h` was
|
||||
/// passed (Zig: `Action.help_error`).
|
||||
pub const HELP_ERROR_NAME: &str = "ActionHelpRequested";
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// This should be returned by actions that want to print the help text
|
||||
/// (Zig: `error.ActionHelpRequested`).
|
||||
#[error("ActionHelpRequested")]
|
||||
ActionHelpRequested,
|
||||
|
||||
/// Argument parsing failed.
|
||||
#[error("{0}")]
|
||||
Args(ArgError),
|
||||
|
||||
/// Loading the configuration failed.
|
||||
#[error("{0}")]
|
||||
Config(#[from] ghostty_config::config::Error),
|
||||
|
||||
#[error("{0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
/// The action exists but depends on functionality that is not ported yet.
|
||||
#[error("the `+{0}` action is not yet available in this build")]
|
||||
NotYetAvailable(&'static str),
|
||||
|
||||
#[error("{0}")]
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl From<ArgError> for Error {
|
||||
fn from(e: ArgError) -> Self {
|
||||
match e {
|
||||
ArgError::Other(ref n) if n == HELP_ERROR_NAME => Error::ActionHelpRequested,
|
||||
e => Error::Args(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::fmt::Error> for Error {
|
||||
fn from(_: std::fmt::Error) -> Self {
|
||||
Error::Other("FormatError".to_string())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user