| author | |
| committer | |
| log | d9081334753cf968c4f695ef2a590d3cb29f10ff |
| tree | be2a76145d4a8e7bd7ea875c9f052274e84d1cd4 |
| parent | 8e60e87abb390e67355abcac566dced0fb481551 |
4 files changed, 16 insertions(+), 12 deletions(-)
src/cmd/aquila/showjson.zig+2-1| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; | 2 | const gpa = std.heap.c_allocator; |
| 3 | const out = std.io.getStdOut().writer(); | ||
| 4 | 3 | ||
| 5 | const u = @import("./../../util/index.zig"); | 4 | const u = @import("./../../util/index.zig"); |
| 6 | const aq = @import("./../aq.zig"); | 5 | const aq = @import("./../aq.zig"); |
| ... | @@ -9,6 +8,8 @@ const aq = @import("./../aq.zig"); | ... | @@ -9,6 +8,8 @@ const aq = @import("./../aq.zig"); |
| 9 | // | 8 | // |
| 10 | 9 | ||
| 11 | pub fn execute(args: [][]u8) !void { | 10 | pub 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); |
| 14 | 15 |
src/cmd/zpm/search.zig+7-6| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; | 2 | const gpa = std.heap.c_allocator; |
| 3 | const out = std.io.getStdOut().writer(); | ||
| 4 | 3 | ||
| 5 | const zfetch = @import("zfetch"); | 4 | const zfetch = @import("zfetch"); |
| 6 | const json = @import("json"); | 5 | const json = @import("json"); |
| ... | @@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig"); | ... | @@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig"); |
| 13 | // | 12 | // |
| 14 | 13 | ||
| 15 | pub fn execute(args: [][]u8) !void { | 14 | pub 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); |
| 18 | 19 | ||
| ... | @@ -57,24 +58,24 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -57,24 +58,24 @@ pub fn execute(args: [][]u8) !void { |
| 57 | }; | 58 | }; |
| 58 | 59 | ||
| 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"); |
| 64 | 65 | ||
| 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); |
| 68 | 69 | ||
| 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); |
| 71 | 72 | ||
| 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 | } |
| 76 | 77 | ||
| 77 | fn print_c_n(c: u8, n: usize) !void { | 78 | fn 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 | // |
| 12 | 12 | ||
| 13 | pub fn execute(args: [][]u8) !void { | 13 | pub 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); |
| 16 | 18 | ||
| 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 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; | 2 | const gpa = std.heap.c_allocator; |
| 3 | const out = std.io.getStdOut().writer(); | ||
| 4 | 3 | ||
| 5 | const zfetch = @import("zfetch"); | 4 | const zfetch = @import("zfetch"); |
| 6 | const json = @import("json"); | 5 | const json = @import("json"); |
| ... | @@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig"); | ... | @@ -13,6 +12,8 @@ const zpm = @import("./../zpm.zig"); |
| 13 | // | 12 | // |
| 14 | 13 | ||
| 15 | pub fn execute(args: [][]u8) !void { | 14 | pub 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); |
| 18 | 19 | ||
| ... | @@ -28,19 +29,19 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -28,19 +29,19 @@ pub fn execute(args: [][]u8) !void { |
| 28 | }; | 29 | }; |
| 29 | 30 | ||
| 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"); |
| 33 | 34 | ||
| 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 | } |
| 42 | 43 | ||
| 43 | fn print_c_n(c: u8, n: usize) !void { | 44 | fn 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 | } |