feat: add --scratch command line parameter

This commit is contained in:
CJ van den Berg 2025-02-13 12:04:02 +01:00
parent 47c7b37968
commit 9bedb9eccd
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -72,6 +72,7 @@ pub fn main() anyerror!void {
.syntax_report_timing = "Report syntax highlighting time", .syntax_report_timing = "Report syntax highlighting time",
.exec = "Execute a command on startup", .exec = "Execute a command on startup",
.literal = "Disable :LINE and +LINE syntax", .literal = "Disable :LINE and +LINE syntax",
.scratch = "Open a scratch (temporary) buffer on start",
.version = "Show build version and exit", .version = "Show build version and exit",
}; };
@ -85,6 +86,7 @@ pub fn main() anyerror!void {
.language = 'l', .language = 'l',
.exec = 'e', .exec = 'e',
.literal = 'L', .literal = 'L',
.scratch = 'S',
.version = 'v', .version = 'v',
}; };
@ -106,6 +108,7 @@ pub fn main() anyerror!void {
syntax_report_timing: bool, syntax_report_timing: bool,
exec: ?[]const u8, exec: ?[]const u8,
literal: bool, literal: bool,
scratch: bool,
version: bool, version: bool,
}; };
@ -316,6 +319,10 @@ pub fn main() anyerror!void {
try tui_proc.send(.{ "cmd", "show_home" }); try tui_proc.send(.{ "cmd", "show_home" });
} }
if (args.scratch) {
try tui_proc.send(.{ "cmd", "create_scratch_buffer", .{} });
}
if (args.exec) |exec_str| { if (args.exec) |exec_str| {
var cmds = std.mem.splitScalar(u8, exec_str, ';'); var cmds = std.mem.splitScalar(u8, exec_str, ';');
while (cmds.next()) |cmd| try tui_proc.send(.{ "cmd", cmd, .{} }); while (cmds.next()) |cmd| try tui_proc.send(.{ "cmd", cmd, .{} });