| ... | @@ -0,0 +1,39 @@ |
| 1 | const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; |
| 3 | const builtin = std.builtin; |
| 4 | |
| 5 | const u = @import("./../util/index.zig"); |
| 6 | |
| 7 | // |
| 8 | // |
| 9 | |
| 10 | pub fn execute(args: [][]u8) !void { |
| 11 | _ = args; |
| 12 | |
| 13 | const root = @import("root"); |
| 14 | const build_options = if (@hasDecl(root, "build_options")) root.build_options else struct {}; |
| 15 | const version = if (@hasDecl(build_options, "version")) build_options.version else "unknown"; |
| 16 | |
| 17 | const stdout = std.io.getStdOut(); |
| 18 | const w = stdout.writer(); |
| 19 | |
| 20 | try w.writeAll("zigmod"); |
| 21 | |
| 22 | try w.print(" {s}", .{version}); |
| 23 | if (std.mem.eql(u8, version, "dev")) { |
| 24 | try w.print( |
| 25 | "-{s}", |
| 26 | .{ |
| 27 | (try u.git_rev_HEAD(gpa, std.fs.cwd()))[0..7], |
| 28 | }, |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | try w.print(" {s}", .{@tagName(builtin.os.tag)}); |
| 33 | |
| 34 | try w.print(" {s}", .{@tagName(builtin.cpu.arch)}); |
| 35 | |
| 36 | try w.print(" {s}", .{@tagName(builtin.abi)}); |
| 37 | |
| 38 | try w.writeAll("\n"); |
| 39 | } |