Skip to content

Commit

Permalink
add 'zigup latest' command
Browse files Browse the repository at this point in the history
adds a command which sets the default compiler to the current local
master version without downloading anything.
  • Loading branch information
travisstaloch committed Apr 3, 2024
1 parent 6aabe15 commit 33dcb5f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions zigup.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ fn help() void {
\\ that aren't the default, master, or marked to keep.
\\ zigup keep VERSION mark a compiler to be kept during clean
\\ zigup run VERSION ARGS... run the given VERSION of the compiler with the given ARGS...
\\ zigup latest set the default compiler to the current local master version without
\\ downloading anything.
\\
\\Uncommon Usage:
\\
Expand Down Expand Up @@ -304,6 +306,18 @@ pub fn main2() !u8 {
std.log.err("'default' command requires 1 or 2 arguments but got {d}", .{args.len - 1});
return 1;
}
if (std.mem.eql(u8, "latest", args[0])) {
if (args.len != 1) {
std.log.err("'latest' command has no arguments", .{});
return 1;
}
const install_dir_string = try getInstallDir(allocator, .{ .create = false });
defer allocator.free(install_dir_string);
const compiler_dir = try std.fs.path.join(allocator, &[_][]const u8{ install_dir_string, "master" });
defer allocator.free(compiler_dir);
try setDefaultCompiler(allocator, compiler_dir, .verify_existence);
return 0;
}
if (args.len == 1) {
try fetchCompiler(allocator, args[0], .set_default);
return 0;
Expand Down Expand Up @@ -466,7 +480,7 @@ pub fn loggyUpdateSymlink(target_path: []const u8, sym_link_path: []const u8, fl
error.NotLink => {
std.debug.print(
"unable to update/overwrite the 'zig' PATH symlink, the file '{s}' already exists and is not a symlink\n",
.{ sym_link_path},
.{sym_link_path},
);
std.os.exit(1);
},
Expand Down Expand Up @@ -884,7 +898,7 @@ fn createExeLink(link_target: []const u8, path_link: []const u8) !void {
error.IsDir => {
std.debug.print(
"unable to create the exe link, the path '{s}' is a directory\n",
.{ path_link},
.{path_link},
);
std.os.exit(1);
},
Expand Down

0 comments on commit 33dcb5f

Please sign in to comment.