@@ -59,6 +59,10 @@ pub fn main() !void {
5959
6060 switch (args .mode ) {
6161 .help = > args .printUsageAndExit (args .mode .help ),
62+ .version = > {
63+ std .debug .print ("{s}\n " , .{@import ("build_info" ).git_commit });
64+ return std .process .cleanExit ();
65+ },
6266 .serve = > | opts | {
6367 const address = std .net .Address .parseIp4 (opts .host , opts .port ) catch | err | {
6468 log .err ("address (host:port) {any}\n " , .{err });
@@ -125,12 +129,14 @@ const Command = struct {
125129 help ,
126130 fetch ,
127131 serve ,
132+ version ,
128133 };
129134
130135 const Mode = union (ModeType ) {
131136 help : bool , // false when being printed because of an error
132137 fetch : Fetch ,
133138 serve : Serve ,
139+ version : void ,
134140 };
135141
136142 const Serve = struct {
@@ -172,10 +178,13 @@ const Command = struct {
172178 \\--timeout Inactivity timeout in seconds before disconnecting clients
173179 \\ Defaults to 3 (seconds)
174180 \\
181+ \\version command
182+ \\Displays the version of {s}
183+ \\
175184 \\help command
176185 \\Displays this message
177186 ;
178- std .debug .print (usage , .{ self .exec_name , self .exec_name , self .exec_name });
187+ std .debug .print (usage , .{ self .exec_name , self .exec_name , self .exec_name , self . exec_name });
179188 if (success ) {
180189 return std .process .cleanExit ();
181190 }
@@ -210,9 +219,10 @@ fn parseArgs(allocator: Allocator) !Command {
210219 };
211220
212221 cmd .mode = switch (mode ) {
213- .help = > Command.Mode { .help = true },
214- .serve = > Command.Mode { .serve = parseServeArgs (allocator , & args ) catch return cmd },
215- .fetch = > Command.Mode { .fetch = parseFetchArgs (allocator , & args ) catch return cmd },
222+ .help = > .{ .help = true },
223+ .serve = > .{ .serve = parseServeArgs (allocator , & args ) catch return cmd },
224+ .fetch = > .{ .fetch = parseFetchArgs (allocator , & args ) catch return cmd },
225+ .version = > .{ .version = {} },
216226 };
217227 return cmd ;
218228}
0 commit comments