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 @@
11const std = @import("std");
22const gpa = std.heap.c_allocator;
3const out = std.io.getStdOut().writer();
43
54const u = @import("./../../util/index.zig");
65const aq = @import("./../aq.zig");
......@@ -9,6 +8,8 @@ const aq = @import("./../aq.zig");
98//
109
1110pub fn execute(args: [][]u8) !void {
11 const out = std.io.getStdOut().writer();
12
1213 const url = try std.mem.join(gpa, "/", &.{ aq.server_root, args[0] });
1314 const val = try aq.server_fetch(url);
1415
src/cmd/zpm/search.zig+7-6
......@@ -1,6 +1,5 @@
11const std = @import("std");
22const gpa = std.heap.c_allocator;
3const out = std.io.getStdOut().writer();
43
54const zfetch = @import("zfetch");
65const json = @import("json");
......@@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig");
1312//
1413
1514pub fn execute(args: [][]u8) !void {
15 const out = std.io.getStdOut().writer();
16
1617 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "packages" });
1718 const val = try zpm.server_fetch(url);
1819
......@@ -57,24 +58,24 @@ pub fn execute(args: [][]u8) !void {
5758 };
5859
5960 try out.writeAll("NAME");
60 try print_c_n(' ', name_col_width - 4);
61 try print_c_n(out, ' ', name_col_width - 4);
6162 try out.writeAll("AUTHOR");
62 try print_c_n(' ', author_col_width - 6);
63 try print_c_n(out, ' ', author_col_width - 6);
6364 try out.writeAll("DESCRIPTION\n");
6465
6566 for (list) |pkg| {
6667 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
6970 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
7273 try out.writeAll(pkg.description);
7374 try out.writeAll("\n");
7475 }
7576}
7677
77fn print_c_n(c: u8, n: usize) !void {
78fn print_c_n(out: anytype, c: u8, n: usize) !void {
7879 for (range(n)) |_| {
7980 try out.writeAll(&.{c});
8081 }
src/cmd/zpm/showjson.zig+2-1
......@@ -11,9 +11,10 @@ const zpm = @import("./../zpm.zig");
1111//
1212
1313pub fn execute(args: [][]u8) !void {
14 const out = std.io.getStdOut().writer();
15
1416 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, args[0] });
1517 const val = try zpm.server_fetch(url);
1618
17 const out = std.io.getStdOut().writer();
1819 try out.print("{}\n", .{val});
1920}
src/cmd/zpm/tags.zig+5-4
......@@ -1,6 +1,5 @@
11const std = @import("std");
22const gpa = std.heap.c_allocator;
3const out = std.io.getStdOut().writer();
43
54const zfetch = @import("zfetch");
65const json = @import("json");
......@@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig");
1312//
1413
1514pub fn execute(args: [][]u8) !void {
15 const out = std.io.getStdOut().writer();
16
1617 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "tags" });
1718 const val = try zpm.server_fetch(url);
1819
......@@ -28,19 +29,19 @@ pub fn execute(args: [][]u8) !void {
2829 };
2930
3031 try out.writeAll("NAME");
31 try print_c_n(' ', name_col_width - 4);
32 try print_c_n(out, ' ', name_col_width - 4);
3233 try out.writeAll("DESCRIPTION\n");
3334
3435 for (val.Array) |tag| {
3536 const name = tag.get("name").?.String;
3637 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);
3839 try out.writeAll(tag.get("description").?.String);
3940 try out.writeAll("\n");
4041 }
4142}
4243
43fn print_c_n(c: u8, n: usize) !void {
44fn print_c_n(out: anytype, c: u8, n: usize) !void {
4445 for (range(n)) |_| {
4546 try out.writeAll(&.{c});
4647 }