mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
apprt/glfw: exit with invalid CLI args
This commit is contained in:
11
src/App.zig
11
src/App.zig
@ -231,10 +231,19 @@ fn drainMailbox(self: *App, rt_app: *apprt.App) !void {
|
||||
.open_config => try self.performAction(rt_app, .open_config),
|
||||
.new_window => |msg| try self.newWindow(rt_app, msg),
|
||||
.close => |surface| self.closeSurface(surface),
|
||||
.quit => self.setQuit(),
|
||||
.surface_message => |msg| try self.surfaceMessage(msg.surface, msg.message),
|
||||
.redraw_surface => |surface| self.redrawSurface(rt_app, surface),
|
||||
.redraw_inspector => |surface| self.redrawInspector(rt_app, surface),
|
||||
|
||||
// If we're quitting, then we set the quit flag and stop
|
||||
// draining the mailbox immediately. This lets us defer
|
||||
// mailbox processing to the next tick so that the apprt
|
||||
// can try to quick as quickly as possible.
|
||||
.quit => {
|
||||
log.info("quit message received, short circuiting mailbox drain", .{});
|
||||
self.setQuit();
|
||||
return;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ const Allocator = std.mem.Allocator;
|
||||
const glfw = @import("glfw");
|
||||
const macos = @import("macos");
|
||||
const objc = @import("objc");
|
||||
const cli = @import("../cli.zig");
|
||||
const input = @import("../input.zig");
|
||||
const internal_os = @import("../os/main.zig");
|
||||
const renderer = @import("../renderer.zig");
|
||||
@ -77,9 +78,18 @@ pub const App = struct {
|
||||
log.warn("configuration error: {s}", .{buf.items});
|
||||
buf.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
// If we have any CLI errors, exit.
|
||||
if (config._diagnostics.containsLocation(.cli)) {
|
||||
log.warn("CLI errors detected, exiting", .{});
|
||||
_ = core_app.mailbox.push(.{
|
||||
.quit = {},
|
||||
}, .{ .forever = {} });
|
||||
}
|
||||
}
|
||||
|
||||
// Queue a single new window that starts on launch
|
||||
// Note: above we may send a quit so this may never happen
|
||||
_ = core_app.mailbox.push(.{
|
||||
.new_window = .{},
|
||||
}, .{ .forever = {} });
|
||||
|
Reference in New Issue
Block a user