Files
ghostty-rs/crates/ghostty-cli/src/list_actions.rs
T
ddidderr 7868e56273 refactor: resolve cross-crate integration TODOs and resources discovery
Cleanup pass over items collected in docs/rewrite/INTEGRATION_TODO.md:
- OSC 133 printf-q / percent decoders live once in
  ghostty_vt::string_encoding; ghostty-os re-exports them.
- CursorStyle and clipboard codepoint map entries have one definition
  (ghostty-terminal); ghostty-config now depends on ghostty-terminal.
- ActionKey::docs() trailing blank lines fixed at the source; cli's
  workaround removed (+list-actions --docs still byte-identical).
- x11_color exposes names in original case; cli no longer re-parses
  rgb.txt.
- One cgroup scope wait loop (ghostty_os::cgroup::wait_for_scope).
- Flatpak passwd lookup implemented in ghostty-os via a local pty.
- +version shows the rustc version captured at build time.

Resources: dev builds find <workspace>/resources automatically (keeping
Ghostty's sentinel-file detection and GHOSTTY_RESOURCES_DIR);
scripts/gen-terminfo.sh (just terminfo) regenerates the compiled
terminfo; `just install [PREFIX]` installs binary, share/ghostty,
terminfo, desktop/D-Bus/systemd/metainfo files and icons.

Test Plan:
- cargo test for vt, os, config, input, cli
- diff `+list-keybinds`, `+list-actions --docs`, `+show-config --default`
  against /usr/bin/ghostty
2026-10-12 02:08:22 +02:00

65 lines
1.7 KiB
Rust

//! `+list-actions` (ZIG/src/cli/list_actions.zig).
use std::io::Write;
use ghostty_config::config_struct;
use crate::error::Error;
config_struct! {
pub struct Options {
/// If `true`, print out documentation about the action associated with the
/// keybinds.
"docs" => docs: bool = false,
}
}
cli_options!(Options, help);
/// The `list-actions` command is used to list all the available keybind
/// actions for Ghostty. These are distinct from the CLI Actions which can
/// be listed via `+help`
///
/// Flags:
///
/// * `--docs`: will print out the documentation for each action.
pub fn run(args: &[String]) -> Result<u8, Error> {
let mut opts = Options::default();
crate::parse_options(&mut opts, args)?;
let out = generate_plaintext(opts.docs);
let mut stdout = std::io::stdout().lock();
stdout.write_all(out.as_bytes())?;
stdout.flush()?;
Ok(0)
}
/// `helpgen_actions.generate(.plaintext, show_docs)`.
#[must_use]
pub fn generate_plaintext(show_docs: bool) -> String {
ghostty_input::helpgen_actions::generate_string(
ghostty_input::helpgen_actions::Format::Plaintext,
show_docs,
)
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn names_only() {
let s = generate_plaintext(false);
assert!(s.starts_with("ignore\nunbind\ncsi\n"));
assert!(!s.contains(':'));
}
#[test]
fn docs_have_no_stray_blank_lines_between_actions() {
let s = generate_plaintext(true);
assert!(s.starts_with("\nignore:\n Ignore this key combination.\n"));
assert!(s.contains(" respectively.\n\njump_to_prompt:\n"));
assert!(s.ends_with('\n'));
}
}