authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-07 21:10:25 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-07 21:10:25 -07:00
logd9081334753cf968c4f695ef2a590d3cb29f10ff
treebe2a76145d4a8e7bd7ea875c9f052274e84d1cd4
parent8e60e87abb390e67355abcac566dced0fb481551

`std.io.getStdOut()` has to be called at runtime


4 files changed, 16 insertions(+), 12 deletions(-)

src/cmd/aquila/showjson.zig+2-1
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const gpa = std.heap.c_allocator;2const gpa = std.heap.c_allocator;
3const out = std.io.getStdOut().writer();
43
5const u = @import("./../../util/index.zig");4const u = @import("./../../util/index.zig");
6const aq = @import("./../aq.zig");5const aq = @import("./../aq.zig");
...@@ -9,6 +8,8 @@ const aq = @import("./../aq.zig");...@@ -9,6 +8,8 @@ const aq = @import("./../aq.zig");
9//8//
109
11pub fn execute(args: [][]u8) !void {10pub fn execute(args: [][]u8) !void {
11 const out = std.io.getStdOut().writer();
12
12 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, args[0] });13 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, args[0] });
13 const val = try aq.server_fetch(url);14 const val = try aq.server_fetch(url);
1415
src/cmd/zpm/search.zig+7-6
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const gpa = std.heap.c_allocator;2const gpa = std.heap.c_allocator;
3const out = std.io.getStdOut().writer();
43
5const zfetch = @import("zfetch");4const zfetch = @import("zfetch");
6const json = @import("json");5const json = @import("json");
...@@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig");...@@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig");
13//12//
1413
15pub fn execute(args: [][]u8) !void {14pub fn execute(args: [][]u8) !void {
15 const out = std.io.getStdOut().writer();
16
16 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "packages" });17 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "packages" });
17 const val = try zpm.server_fetch(url);18 const val = try zpm.server_fetch(url);
1819
...@@ -57,24 +58,24 @@ pub fn execute(args: [][]u8) !void {...@@ -57,24 +58,24 @@ pub fn execute(args: [][]u8) !void {
57 };58 };
5859
59 try out.writeAll("NAME");60 try out.writeAll("NAME");
60 try print_c_n(' ', name_col_width - 4);61 try print_c_n(out, ' ', name_col_width - 4);
61 try out.writeAll("AUTHOR");62 try out.writeAll("AUTHOR");
62 try print_c_n(' ', author_col_width - 6);63 try print_c_n(out, ' ', author_col_width - 6);
63 try out.writeAll("DESCRIPTION\n");64 try out.writeAll("DESCRIPTION\n");
6465
65 for (list) |pkg| {66 for (list) |pkg| {
66 try out.writeAll(pkg.name);67 try out.writeAll(pkg.name);
67 try print_c_n(' ', name_col_width - pkg.name.len);68 try print_c_n(out, ' ', name_col_width - pkg.name.len);
6869
69 try out.writeAll(pkg.author);70 try out.writeAll(pkg.author);
70 try print_c_n(' ', author_col_width - pkg.author.len);71 try print_c_n(out, ' ', author_col_width - pkg.author.len);
7172
72 try out.writeAll(pkg.description);73 try out.writeAll(pkg.description);
73 try out.writeAll("\n");74 try out.writeAll("\n");
74 }75 }
75}76}
7677
77fn print_c_n(c: u8, n: usize) !void {78fn print_c_n(out: anytype, c: u8, n: usize) !void {
78 for (range(n)) |_| {79 for (range(n)) |_| {
79 try out.writeAll(&.{c});80 try out.writeAll(&.{c});
80 }81 }
src/cmd/zpm/showjson.zig+2-1
...@@ -11,9 +11,10 @@ const zpm = @import("./../zpm.zig");...@@ -11,9 +11,10 @@ const zpm = @import("./../zpm.zig");
11//11//
1212
13pub fn execute(args: [][]u8) !void {13pub fn execute(args: [][]u8) !void {
14 const out = std.io.getStdOut().writer();
15
14 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, args[0] });16 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, args[0] });
15 const val = try zpm.server_fetch(url);17 const val = try zpm.server_fetch(url);
1618
17 const out = std.io.getStdOut().writer();
18 try out.print("{}\n", .{val});19 try out.print("{}\n", .{val});
19}20}
src/cmd/zpm/tags.zig+5-4
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const gpa = std.heap.c_allocator;2const gpa = std.heap.c_allocator;
3const out = std.io.getStdOut().writer();
43
5const zfetch = @import("zfetch");4const zfetch = @import("zfetch");
6const json = @import("json");5const json = @import("json");
...@@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig");...@@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig");
13//12//
1413
15pub fn execute(args: [][]u8) !void {14pub fn execute(args: [][]u8) !void {
15 const out = std.io.getStdOut().writer();
16
16 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "tags" });17 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "tags" });
17 const val = try zpm.server_fetch(url);18 const val = try zpm.server_fetch(url);
1819
...@@ -28,19 +29,19 @@ pub fn execute(args: [][]u8) !void {...@@ -28,19 +29,19 @@ pub fn execute(args: [][]u8) !void {
28 };29 };
2930
30 try out.writeAll("NAME");31 try out.writeAll("NAME");
31 try print_c_n(' ', name_col_width - 4);32 try print_c_n(out, ' ', name_col_width - 4);
32 try out.writeAll("DESCRIPTION\n");33 try out.writeAll("DESCRIPTION\n");
3334
34 for (val.Array) |tag| {35 for (val.Array) |tag| {
35 const name = tag.get("name").?.String;36 const name = tag.get("name").?.String;
36 try out.writeAll(name);37 try out.writeAll(name);
37 try print_c_n(' ', name_col_width - name.len);38 try print_c_n(out, ' ', name_col_width - name.len);
38 try out.writeAll(tag.get("description").?.String);39 try out.writeAll(tag.get("description").?.String);
39 try out.writeAll("\n");40 try out.writeAll("\n");
40 }41 }
41}42}
4243
43fn print_c_n(c: u8, n: usize) !void {44fn print_c_n(out: anytype, c: u8, n: usize) !void {
44 for (range(n)) |_| {45 for (range(n)) |_| {
45 try out.writeAll(&.{c});46 try out.writeAll(&.{c});
46 }47 }