add a spinner to oizys dry

This commit is contained in:
Daylin Morgan 2024-05-13 17:34:45 -05:00
parent 281ea401d2
commit 96cf7e126c
Signed by: daylin
GPG key ID: 950D13E9719334AD
5 changed files with 19 additions and 2 deletions

View file

@ -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);

View file

@ -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 = .{""},
}

View file

@ -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="
}
}

View file

@ -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);

View file

@ -24,5 +24,4 @@ pub fn main() !void {
var oizys = try Oizys.init(allocator, cli.matches, cli.forward);
defer oizys.deinit();
try oizys.run();
}