summaryrefslogtreecommitdiff
path: root/src/cli/version.zig
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2024-01-20 09:29:26 -0800
committerMitchell Hashimoto <mitchell.hashimoto@gmail.com>2024-01-20 09:29:26 -0800
commitb438998fb82d07e7f29a71cec30e1f46a7a7a0fc (patch)
treeee31f31c74b0edad5daf1b7f60dfe737b8005261 /src/cli/version.zig
parent203b38fdac0b18d0e26418390dcaca914357c28c (diff)
cli: support --help and -h for actions
Diffstat (limited to 'src/cli/version.zig')
-rw-r--r--src/cli/version.zig26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/cli/version.zig b/src/cli/version.zig
index dca20ad2f..fb12faa2e 100644
--- a/src/cli/version.zig
+++ b/src/cli/version.zig
@@ -1,12 +1,36 @@
const std = @import("std");
+const Allocator = std.mem.Allocator;
const builtin = @import("builtin");
const build_config = @import("../build_config.zig");
const xev = @import("xev");
const renderer = @import("../renderer.zig");
+const args = @import("args.zig");
+const Action = @import("action.zig").Action;
+
+pub const Options = struct {
+ pub fn deinit(self: Options) void {
+ _ = self;
+ }
+
+ /// Enables "-h" and "--help" to work.
+ pub fn help(self: Options) !void {
+ _ = self;
+ return Action.help_error;
+ }
+};
/// The `version` command is used to display information
/// about Ghostty.
-pub fn run() !u8 {
+pub fn run(alloc: Allocator) !u8 {
+ var opts: Options = .{};
+ defer opts.deinit();
+
+ {
+ var iter = try std.process.argsWithAllocator(alloc);
+ defer iter.deinit();
+ try args.parse(Options, alloc, &opts, &iter);
+ }
+
const stdout = std.io.getStdOut().writer();
try stdout.print("Ghostty {s}\n\n", .{build_config.version_string});
try stdout.print("Build Config\n", .{});