Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'zigup latest' command #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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