mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
cli: invert special case arg parsing logic
Invert special case logic so that we can add additional cases. The previous logic bailed if we weren't the only special case ('-e').
This commit is contained in:
@ -1630,9 +1630,7 @@ pub fn finalize(self: *Config) !void {
|
|||||||
/// Callback for src/cli/args.zig to allow us to handle special cases
|
/// Callback for src/cli/args.zig to allow us to handle special cases
|
||||||
/// like `--help` or `-e`. Returns "false" if the CLI parsing should halt.
|
/// like `--help` or `-e`. Returns "false" if the CLI parsing should halt.
|
||||||
pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter: anytype) !bool {
|
pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter: anytype) !bool {
|
||||||
// If it isn't "-e" then we just continue parsing normally.
|
if (std.mem.eql(u8, arg, "-e")) {
|
||||||
if (!std.mem.eql(u8, arg, "-e")) return true;
|
|
||||||
|
|
||||||
// Build up the command. We don't clean this up because we take
|
// Build up the command. We don't clean this up because we take
|
||||||
// ownership in our allocator.
|
// ownership in our allocator.
|
||||||
var command = std.ArrayList(u8).init(alloc);
|
var command = std.ArrayList(u8).init(alloc);
|
||||||
@ -1659,6 +1657,10 @@ pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter:
|
|||||||
|
|
||||||
// Do not continue, we consumed everything.
|
// Do not continue, we consumed everything.
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we didn't find a special case, continue parsing normally
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a shallow copy of this config. This will share all the memory
|
/// Create a shallow copy of this config. This will share all the memory
|
||||||
|
Reference in New Issue
Block a user