From 1947afade94ccfd24f49c7efe8aeac735eb08061 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 22 Jun 2025 11:22:02 -0700 Subject: `input` configuration to pass input as stdin on startup This adds a new configuration `input` that allows passing either raw text or file contents as stdin when starting the terminal. The input is sent byte-for-byte to the terminal, so control characters such as `\n` will be interpreted by the shell and can be used to run programs in the context of the loaded shell. Example: `ghostty --input="hello, world\n"` will start the your default shell, run `echo hello, world`, and then show the prompt. --- src/cli/args.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/cli/args.zig') diff --git a/src/cli/args.zig b/src/cli/args.zig index 68972a622..3c34e17fe 100644 --- a/src/cli/args.zig +++ b/src/cli/args.zig @@ -414,7 +414,7 @@ pub fn parseIntoField( return error.InvalidField; } -fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T { +pub fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T { const info = @typeInfo(T).@"union"; assert(@typeInfo(info.tag_type.?) == .@"enum"); @@ -1090,6 +1090,7 @@ test "parseIntoField: tagged union" { b: u8, c: void, d: []const u8, + e: [:0]const u8, } = undefined, } = .{}; @@ -1108,6 +1109,10 @@ test "parseIntoField: tagged union" { // Set string field try parseIntoField(@TypeOf(data), alloc, &data, "value", "d:hello"); try testing.expectEqualStrings("hello", data.value.d); + + // Set sentinel string field + try parseIntoField(@TypeOf(data), alloc, &data, "value", "e:hello"); + try testing.expectEqualStrings("hello", data.value.e); } test "parseIntoField: tagged union unknown filed" { -- cgit v1.2.3