aboutsummaryrefslogtreecommitdiff
path: root/src/cli/install_completions_command.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/install_completions_command.zig')
-rw-r--r--src/cli/install_completions_command.zig43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/cli/install_completions_command.zig b/src/cli/install_completions_command.zig
index 3b8206a33..3f224c161 100644
--- a/src/cli/install_completions_command.zig
+++ b/src/cli/install_completions_command.zig
@@ -93,6 +93,7 @@ pub const InstallCompletionsCommand = struct {
const fail_exit_code: u8 = if (bun.getenvZ("IS_BUN_AUTO_UPDATE") == null) 1 else 0;
var cwd_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+
var stdout = std.io.getStdOut();
var shell = ShellCompletions.Shell.unknown;
@@ -131,7 +132,7 @@ pub const InstallCompletionsCommand = struct {
}
var completions_dir: string = "";
- var output_dir: std.fs.Dir = found: {
+ var output_dir: std.fs.IterableDir = found: {
for (std.os.argv) |arg, i| {
if (strings.eqlComptime(std.mem.span(arg), "completions")) {
if (std.os.argv.len > i + 1) {
@@ -152,9 +153,7 @@ pub const InstallCompletionsCommand = struct {
Global.exit(fail_exit_code);
}
- break :found std.fs.openDirAbsolute(completions_dir, .{
- .iterate = true,
- }) catch |err| {
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch |err| {
Output.prettyErrorln("<r><red>error:<r> accessing {s} errored {s}", .{ completions_dir, @errorName(err) });
Global.exit(fail_exit_code);
};
@@ -170,7 +169,7 @@ pub const InstallCompletionsCommand = struct {
outer: {
var paths = [_]string{ std.mem.span(config_dir), "./fish/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -180,7 +179,7 @@ pub const InstallCompletionsCommand = struct {
var paths = [_]string{ std.mem.span(data_dir), "./fish/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -189,7 +188,7 @@ pub const InstallCompletionsCommand = struct {
outer: {
var paths = [_]string{ std.mem.span(home_dir), "./.config/fish/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -199,12 +198,12 @@ pub const InstallCompletionsCommand = struct {
if (!Environment.isAarch64) {
// homebrew fish
completions_dir = "/usr/local/share/fish/completions";
- break :found std.fs.openDirAbsoluteZ("/usr/local/share/fish/completions", .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute("/usr/local/share/fish/completions", .{}) catch
break :outer;
} else {
// homebrew fish
completions_dir = "/opt/homebrew/share/fish/completions";
- break :found std.fs.openDirAbsoluteZ("/opt/homebrew/share/fish/completions", .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute("/opt/homebrew/share/fish/completions", .{}) catch
break :outer;
}
}
@@ -212,7 +211,7 @@ pub const InstallCompletionsCommand = struct {
outer: {
completions_dir = "/etc/fish/completions";
- break :found std.fs.openDirAbsoluteZ("/etc/fish/completions", .{ .iterate = true }) catch break :outer;
+ break :found std.fs.openIterableDirAbsolute("/etc/fish/completions", .{}) catch break :outer;
}
},
.zsh => {
@@ -221,7 +220,7 @@ pub const InstallCompletionsCommand = struct {
while (splitter.next()) |dir| {
completions_dir = dir;
- break :found std.fs.openDirAbsolute(dir, .{ .iterate = true }) catch continue;
+ break :found std.fs.openIterableDirAbsolute(dir, .{}) catch continue;
}
}
@@ -230,7 +229,7 @@ pub const InstallCompletionsCommand = struct {
var paths = [_]string{ std.mem.span(data_dir), "./zsh-completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -238,7 +237,7 @@ pub const InstallCompletionsCommand = struct {
if (bun.getenvZ("BUN_INSTALL")) |home_dir| {
outer: {
completions_dir = home_dir;
- break :found std.fs.openDirAbsolute(home_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(home_dir, .{}) catch
break :outer;
}
}
@@ -248,7 +247,7 @@ pub const InstallCompletionsCommand = struct {
outer: {
var paths = [_]string{ std.mem.span(home_dir), "./.oh-my-zsh/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -257,7 +256,7 @@ pub const InstallCompletionsCommand = struct {
outer: {
var paths = [_]string{ std.mem.span(home_dir), "./.bun" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -272,7 +271,7 @@ pub const InstallCompletionsCommand = struct {
for (dirs_to_try) |dir| {
completions_dir = dir;
- break :found std.fs.openDirAbsolute(dir, .{ .iterate = true }) catch continue;
+ break :found std.fs.openIterableDirAbsolute(dir, .{}) catch continue;
}
},
.bash => {
@@ -280,7 +279,7 @@ pub const InstallCompletionsCommand = struct {
outer: {
var paths = [_]string{ std.mem.span(data_dir), "./bash-completion/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -290,7 +289,7 @@ pub const InstallCompletionsCommand = struct {
var paths = [_]string{ std.mem.span(config_dir), "./bash-completion/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -301,7 +300,7 @@ pub const InstallCompletionsCommand = struct {
var paths = [_]string{ std.mem.span(home_dir), "./.oh-my-bash/custom/completions" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -310,7 +309,7 @@ pub const InstallCompletionsCommand = struct {
var paths = [_]string{ std.mem.span(home_dir), "./.bash_completion.d" };
completions_dir = resolve_path.joinAbsString(cwd, &paths, .auto);
- break :found std.fs.openDirAbsolute(completions_dir, .{ .iterate = true }) catch
+ break :found std.fs.openIterableDirAbsolute(completions_dir, .{}) catch
break :outer;
}
}
@@ -323,7 +322,7 @@ pub const InstallCompletionsCommand = struct {
for (dirs_to_try) |dir| {
completions_dir = dir;
- break :found std.fs.openDirAbsolute(dir, .{ .iterate = true }) catch continue;
+ break :found std.fs.openIterableDirAbsolute(dir, .{}) catch continue;
}
},
else => unreachable,
@@ -357,7 +356,7 @@ pub const InstallCompletionsCommand = struct {
std.debug.assert(completions_dir.len > 0);
- var output_file = output_dir.createFileZ(filename, .{
+ var output_file = output_dir.dir.createFileZ(filename, .{
.truncate = true,
}) catch |err| {
Output.prettyErrorln("<r><red>error:<r> Could not open {s} for writing: {s}", .{