mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-27 11:06:31 +00:00
zsh: add completions generation
This commit is contained in:
@@ -163,6 +163,26 @@ pub const Action = enum {
|
||||
return "cli/" ++ filename ++ ".zig";
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the options of action. Supports generating shell completions
|
||||
/// without duplicating the mapping from Action to relevant Option
|
||||
/// @import(..) declaration.
|
||||
pub fn options(comptime self: Action) type {
|
||||
comptime {
|
||||
return switch (self) {
|
||||
.version => version.Options,
|
||||
.help => help.Options,
|
||||
.@"list-fonts" => list_fonts.Options,
|
||||
.@"list-keybinds" => list_keybinds.Options,
|
||||
.@"list-themes" => list_themes.Options,
|
||||
.@"list-colors" => list_colors.Options,
|
||||
.@"list-actions" => list_actions.Options,
|
||||
.@"show-config" => show_config.Options,
|
||||
.@"validate-config" => validate_config.Options,
|
||||
.@"crash-report" => crash_report.Options,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
test "parse action none" {
|
||||
|
||||
@@ -7,7 +7,7 @@ const font = @import("../font/main.zig");
|
||||
|
||||
const log = std.log.scoped(.list_fonts);
|
||||
|
||||
pub const Config = struct {
|
||||
pub const Options = struct {
|
||||
/// This is set by the CLI parser for deinit.
|
||||
_arena: ?ArenaAllocator = null,
|
||||
|
||||
@@ -23,13 +23,13 @@ pub const Config = struct {
|
||||
bold: bool = false,
|
||||
italic: bool = false,
|
||||
|
||||
pub fn deinit(self: *Config) void {
|
||||
pub fn deinit(self: *Options) void {
|
||||
if (self._arena) |arena| arena.deinit();
|
||||
self.* = undefined;
|
||||
}
|
||||
|
||||
/// Enables "-h" and "--help" to work.
|
||||
pub fn help(self: Config) !void {
|
||||
pub fn help(self: Options) !void {
|
||||
_ = self;
|
||||
return Action.help_error;
|
||||
}
|
||||
@@ -59,9 +59,9 @@ pub fn run(alloc: Allocator) !u8 {
|
||||
}
|
||||
|
||||
fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 {
|
||||
var config: Config = .{};
|
||||
var config: Options = .{};
|
||||
defer config.deinit();
|
||||
try args.parse(Config, alloc_gpa, &config, argsIter);
|
||||
try args.parse(Options, alloc_gpa, &config, argsIter);
|
||||
|
||||
// Use an arena for all our memory allocs
|
||||
var arena = ArenaAllocator.init(alloc_gpa);
|
||||
|
||||
@@ -7,6 +7,8 @@ const xev = @import("xev");
|
||||
const renderer = @import("../renderer.zig");
|
||||
const gtk = if (build_config.app_runtime == .gtk) @import("../apprt/gtk/c.zig").c else void;
|
||||
|
||||
pub const Options = struct {};
|
||||
|
||||
/// The `version` command is used to display information about Ghostty.
|
||||
pub fn run(alloc: Allocator) !u8 {
|
||||
_ = alloc;
|
||||
|
||||
Reference in New Issue
Block a user