authorgravatar for sentrycraft123@gmail.comJan200101 <sentrycraft123@gmail.com> 2026-04-18 20:58:45+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-20 16:38:05-07:00
log5586a1f4eef7103398c595aed451157a07d15e27
tree8a0fd6810173b33fb391d5a3209bd21c6ac0c4b0
parent98cc059622cd5cad3eef1bbc851437358d259033

zig fetch: add option to overwrite the package directory


1 files changed, 7 insertions(+), 1 deletions(-)

src/main.zig+7-1
......@@ -7032,6 +7032,7 @@ const usage_fetch =
70327032 \\Options:
70337033 \\ -h, --help Print this help and exit
70347034 \\ --global-cache-dir [path] Override path to global Zig cache directory
7035 \\ --pkg-dir [path] Override path to package directory
70357036 \\ --debug-hash Print verbose hash information to stdout
70367037 \\ --save Add the fetched package to build.zig.zon
70377038 \\ --save=[name] Add the fetched package to build.zig.zon as name
......@@ -7052,6 +7053,7 @@ fn cmdFetch(
70527053 const color: Color = .auto;
70537054 var opt_path_or_url: ?[]const u8 = null;
70547055 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
7056 var override_pkg_dir: ?[]const u8 = null;
70557057 var debug_hash: bool = false;
70567058 var save: union(enum) {
70577059 no,
......@@ -7071,6 +7073,10 @@ fn cmdFetch(
70717073 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
70727074 i += 1;
70737075 override_global_cache_dir = args[i];
7076 } else if (mem.eql(u8, arg, "--pkg-dir")) {
7077 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
7078 i += 1;
7079 override_pkg_dir = args[i];
70747080 } else if (mem.eql(u8, arg, "--debug-hash")) {
70757081 debug_hash = true;
70767082 } else if (mem.eql(u8, arg, "--save")) {
......@@ -7132,7 +7138,7 @@ fn cmdFetch(
71327138 .local_cache = local_cache_path,
71337139 .root_pkg_path = .{
71347140 .root_dir = build_root.directory,
7135 .sub_path = "zig-pkg",
7141 .sub_path = override_pkg_dir orelse "zig-pkg",
71367142 },
71377143 .recursive = false,
71387144 .read_only = false,