const std = @import("std"); const zup = @import("root"); const Config = zup.Config; const Installation = zup.Installation; // TODO: A way to specify a subset? pub const params = ""; pub const description = "Updates all installed Zig versions."; pub const min_args = 0; pub const max_args = 0; pub fn main(comptime Result: type, config: Config, _: Result) !void { const allocator = config.allocator; var installed = try Installation.getInstalledList(allocator); defer Installation.deinitMap(allocator, &installed); var available = try Installation.getAvailableList(config); defer Installation.deinitMap(allocator, &available); var it = installed.iterator(); while (it.next()) |kv| { const name = kv.key_ptr.*; const inst = kv.value_ptr.*; if (available.get(name)) |avail| { if (avail.version.order(inst.version) == .gt) { std.log.info("Updating {s} from {f} to {f}...", .{ name, inst.version, avail.version }); try zup.install.base.perform(allocator, name, true, available); } } } std.log.info("Done updating", .{}); }