Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/maintenance.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub fn do_maint(args: [][]u8, install_dir: []const u8) !void {
logger.warn("No sub-command provided!", .{});
} else {
if (std.mem.eql(u8, args[0], "uninstall")) {
try do_uninstall(install_dir);
const confirmed = args.len >= 2 and std.mem.eql(u8, args[1], "confirmed");
try do_uninstall(install_dir, confirmed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick, but I would prefer this be called the inverse: -no-confirm or something like that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed the option to --no-confirm :)

}

if (std.mem.eql(u8, args[0], "directory")) {
Expand Down Expand Up @@ -41,12 +42,14 @@ fn confirm() !bool {
}
}

fn do_uninstall(install_dir: []const u8) !void {
logger.warn("This will uninstall the application runtime for this Burrito binary!", .{});
if ((try confirm()) == false) {
logger.warn("Uninstall was aborted!", .{});
logger.info("Quitting.", .{});
return;
fn do_uninstall(install_dir: []const u8, auto_confirmed: bool) !void {
if (!auto_confirmed) {
logger.warn("This will uninstall the application runtime for this Burrito binary!", .{});
if ((try confirm()) == false) {
logger.warn("Uninstall was aborted!", .{});
logger.info("Quitting.", .{});
return;
}
}

logger.info("Deleting directory: {s}", .{install_dir});
Expand All @@ -55,6 +58,13 @@ fn do_uninstall(install_dir: []const u8) !void {
logger.info("Quitting.", .{});
}

fn do_uninstall_confirmed(install_dir: []const u8) !void {
logger.info("Deleting directory: {s}", .{install_dir});
try std.fs.deleteTreeAbsolute(install_dir);
logger.info("Uninstall complete!", .{});
logger.info("Quitting.", .{});
}

fn print_metadata() !void {
var stdout = std.io.getStdOut().writer();
stdout.print("{s}", .{wrapper.RELEASE_METADATA_JSON}) catch {};
Expand Down