From 96cf7e126cb07bbf415f7f307ab39ea4804c2532 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 13 May 2024 17:34:45 -0500 Subject: [PATCH] add a spinner to oizys dry --- pkgs/oizys/oizys-zig/build.zig | 3 ++- pkgs/oizys/oizys-zig/build.zig.zon | 4 ++++ pkgs/oizys/oizys-zig/build.zig.zon2json-lock | 5 +++++ pkgs/oizys/oizys-zig/src/Oizys.zig | 8 ++++++++ pkgs/oizys/oizys-zig/src/main.zig | 1 - 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkgs/oizys/oizys-zig/build.zig b/pkgs/oizys/oizys-zig/build.zig index ef6f86c..2defe61 100644 --- a/pkgs/oizys/oizys-zig/build.zig +++ b/pkgs/oizys/oizys-zig/build.zig @@ -11,7 +11,8 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, }); - exe.root_module.addImport("yazap", b.dependency("yazap", .{ .target = target }).module("yazap")); + exe.root_module.addImport("yazap", b.dependency("yazap", .{}).module("yazap")); + exe.root_module.addImport("donuts", b.dependency("donuts", .{}).module("donuts")); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); diff --git a/pkgs/oizys/oizys-zig/build.zig.zon b/pkgs/oizys/oizys-zig/build.zig.zon index 3955b5c..9d252e8 100644 --- a/pkgs/oizys/oizys-zig/build.zig.zon +++ b/pkgs/oizys/oizys-zig/build.zig.zon @@ -6,6 +6,10 @@ .url = "git+https://github.com/prajwalch/yazap.git#341750ff62e3102da4a7f8233920aebace1fc337", .hash = "1220fa71798c994044a987cbde6e73af76bfc402117a61971ccf48f4af4b7154e8d3", }, + .donuts = .{ + .url = "git+https://github.com/daylinmorgan/donuts.git#b454b9c1fa3084e6d1431f399d133afe31d4235a", + .hash = "1220b6bf5f90c96bd9ac86d989aa1afd605522463afa7f8f372cdf24fac65a5eed99", + }, }, .paths = .{""}, } diff --git a/pkgs/oizys/oizys-zig/build.zig.zon2json-lock b/pkgs/oizys/oizys-zig/build.zig.zon2json-lock index bc5c02e..e13eea3 100644 --- a/pkgs/oizys/oizys-zig/build.zig.zon2json-lock +++ b/pkgs/oizys/oizys-zig/build.zig.zon2json-lock @@ -3,5 +3,10 @@ "name": "yazap", "url": "git+https://github.com/prajwalch/yazap.git#341750ff62e3102da4a7f8233920aebace1fc337", "hash": "sha256-nNhFpay+xk0Ix3GAT1fZ2q/bD9AAx7Xkl4X7QxlzK0M=" + }, + "1220b6bf5f90c96bd9ac86d989aa1afd605522463afa7f8f372cdf24fac65a5eed99": { + "name": "donuts", + "url": "git+https://github.com/daylinmorgan/donuts.git#b454b9c1fa3084e6d1431f399d133afe31d4235a", + "hash": "sha256-q3FcUMdhpiyoqlwj5FbIVdUszeAoYzVFzGTgfWzm/pU=" } } diff --git a/pkgs/oizys/oizys-zig/src/Oizys.zig b/pkgs/oizys/oizys-zig/src/Oizys.zig index ac0b9cf..efa8c0a 100644 --- a/pkgs/oizys/oizys-zig/src/Oizys.zig +++ b/pkgs/oizys/oizys-zig/src/Oizys.zig @@ -2,6 +2,7 @@ const Oizys = @This(); const std = @import("std"); const ArgMatches = @import("yazap").ArgMatches; const Allocator = std.mem.Allocator; +const Donuts = @import("donuts").Donuts; allocator: Allocator, flake: []const u8, @@ -178,10 +179,17 @@ const DryResult = struct { }; pub fn dry(self: *Oizys) !void { + var sp = Donuts(std.io.getStdOut()).init( + "evaluating...", + .{ .style = .dots }, + .{}, + ); + try sp.start(); const cmd_output = try std.ChildProcess.run(.{ .allocator = self.allocator, .argv = &.{ "nix", "build", self.output, "--dry-run" }, }); + try sp.stop(.{ .message = "done." }); defer self.allocator.free(cmd_output.stdout); defer self.allocator.free(cmd_output.stderr); var result = try DryResult.parse(self.allocator, cmd_output.stderr); diff --git a/pkgs/oizys/oizys-zig/src/main.zig b/pkgs/oizys/oizys-zig/src/main.zig index 9a655fc..bd61c7a 100644 --- a/pkgs/oizys/oizys-zig/src/main.zig +++ b/pkgs/oizys/oizys-zig/src/main.zig @@ -24,5 +24,4 @@ pub fn main() !void { var oizys = try Oizys.init(allocator, cli.matches, cli.forward); defer oizys.deinit(); try oizys.run(); - }