const std = @import("std"); const xdg = @import("xdg"); const zup = @import("root"); const Config = zup.Config; const Installation = zup.Installation; pub const params = \\-f, --force Remove even if it is the active installation \\ ; pub const description = "Removes an installed Zig version. Run `zup list -i` to see installed s."; pub const min_args = 1; pub const max_args = 1; pub fn main(comptime Result: type, config: Config, res: Result) !void { const allocator = config.allocator; const name = res.positionals[0]; if (!try Installation.isInstalled(allocator, name)) { std.log.err("{s} is not installed!", .{name}); return error.InstallationNotFound; } const is_active = try Installation.isActive(allocator, name); if (is_active and res.args.force == 0) { std.log.err("{s} is the active installation, not removing without --force!", .{name}); return error.CantRemove; } var data_home = try xdg.openDataHome(allocator, "zup"); defer data_home.close(); std.log.info("Removing {s}...", .{name}); try data_home.deleteTree(name); if (is_active) { var bin_home = try xdg.openBinHome(allocator); defer bin_home.close(); try bin_home.deleteFile("zig"); } std.log.info("Done", .{}); }