aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/libghostty-vt/src/cli/help.zig
diff options
context:
space:
mode:
authorsl0p <sl0p@sl0p.foo>2026-08-13 22:00:03 +0200
committersl0p <sl0p@sl0p.foo>2026-08-13 22:00:03 +0200
commit2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8 (patch)
tree7cd6274303ba1da1f8bd57371aec336dd687fb58 /vendor/libghostty-vt/src/cli/help.zig
downloadslosh-2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8.tar.gz
slosh-2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8.tar.xz
slosh-2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8.zip
sl0ptty: M0 — libghostty-vt vendored, one pane, compositor, diff renderer
Design contract in DESIGN.md. libghostty-vt vendored fresh from ghostty main@bedb6f2 (zig 0.16), built to a 14MB static lib. M0: pty spawn (no libutil), a lib-vt terminal per pane, a screen cell buffer, a diff emitter that repaints only what changed, raw mode, SIGWINCH, and a ~120Hz frame cap that coalesces pty reads. Also the seed of the headless harness: --headless dumps the composited screen without a tty, so composition is testable in milliseconds. tests/live_m0.py covers what headless cannot: raw mode, the diff emitter, resize propagation, and the quit path. 6/6 green.
Diffstat (limited to 'vendor/libghostty-vt/src/cli/help.zig')
-rw-r--r--vendor/libghostty-vt/src/cli/help.zig79
1 files changed, 79 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/cli/help.zig b/vendor/libghostty-vt/src/cli/help.zig
new file mode 100644
index 0000000..755aa12
--- /dev/null
+++ b/vendor/libghostty-vt/src/cli/help.zig
@@ -0,0 +1,79 @@
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+const args = @import("args.zig");
+const Action = @import("ghostty.zig").Action;
+const global = @import("../global.zig");
+
+// Note that this options struct doesn't implement the `help` decl like other
+// actions. That is because the help command is special and wants to handle its
+// own logic around help detection.
+pub const Options = struct {
+ /// This must be registered so that it isn't an error to pass `--help`
+ help: bool = false,
+
+ pub fn deinit(self: Options) void {
+ _ = self;
+ }
+};
+
+/// The `help` command shows general help about Ghostty. Recognized as either
+/// `-h, `--help`, or like other actions `+help`.
+///
+/// You can also specify `--help` or `-h` along with any action such as
+/// `+list-themes` to see help for a specific action.
+pub fn run(alloc: Allocator) !u8 {
+ var opts: Options = .{};
+ defer opts.deinit();
+
+ {
+ var iter = try args.argsIterator(alloc, global.args());
+ defer iter.deinit();
+ try args.parse(Options, alloc, &opts, &iter);
+ }
+
+ var buffer: [2048]u8 = undefined;
+ var stdout_writer = std.Io.File.stdout().writer(global.io(), &buffer);
+ const stdout = &stdout_writer.interface;
+ try stdout.writeAll(
+ \\Usage: ghostty [+action] [options]
+ \\
+ \\Run the Ghostty terminal emulator or a specific helper action.
+ \\
+ \\If no `+action` is specified, run the Ghostty terminal emulator.
+ \\All configuration keys are available as command line options.
+ \\To specify a configuration key, use the `--<key>=<value>` syntax
+ \\where key and value are the same format you'd put into a configuration
+ \\file. For example, `--font-size=12` or `--font-family="Fira Code"`.
+ \\
+ \\To see a list of all available configuration options, please see
+ \\the `src/config/Config.zig` file. A future update will allow seeing
+ \\the list of configuration options from the command line.
+ \\
+ \\A special command line argument `-e <command>` can be used to run
+ \\the specific command inside the terminal emulator. For example,
+ \\`ghostty -e top` will run the `top` command inside the terminal.
+ \\
+ \\On macOS, launching the terminal emulator from the CLI is not
+ \\supported and only actions are supported. Use `open -na Ghostty.app`
+ \\instead, or `open -na ghostty.app --args --foo=bar --baz=quz` to pass
+ \\arguments.
+ \\
+ \\Available actions:
+ \\
+ \\
+ );
+
+ inline for (@typeInfo(Action).@"enum".fields) |field| {
+ try stdout.print(" +{s}\n", .{field.name});
+ }
+
+ try stdout.writeAll(
+ \\
+ \\Specify `+<action> --help` to see the help for a specific action,
+ \\where `<action>` is one of actions listed above.
+ \\
+ );
+ try stdout.flush();
+
+ return 0;
+}