authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-07 19:38:55 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-07 19:38:55 -07:00
log46a869c8cba9ee4d45c284528bc928887b90f0ed
tree6cafca52e7513b394a801fa13928b569ef450702
parentbb3fd063b8560ce4b11e2b800656ad9c9308b3dc

cmd/zpm: move Package struct def to zpm namespace


2 files changed, 11 insertions(+), 12 deletions(-)

src/cmd/zpm.zig+9
......@@ -17,6 +17,15 @@ pub const commands = struct {
1717
1818pub const server_root = "https://zpm.random-projects.net/api";
1919
20pub const Package = struct {
21 author: []const u8,
22 name: []const u8,
23 tags: [][]const u8,
24 git: []const u8,
25 root_file: ?[]const u8,
26 description: []const u8,
27};
28
2029pub fn execute(args: [][]u8) !void {
2130 if (args.len == 0) {
2231 std.debug.warn("{s}\n", .{
src/cmd/zpm_add.zig+2-12
......@@ -4,21 +4,11 @@ const gpa = std.heap.c_allocator;
44const zfetch = @import("zfetch");
55
66const u = @import("./../util/index.zig");
7const zpm = @import("./zpm.zig");
78
89//
910//
1011
11pub const Zpm = struct {
12 pub const Package = struct {
13 author: []const u8,
14 name: []const u8,
15 tags: [][]const u8,
16 git: []const u8,
17 root_file: ?[]const u8,
18 description: []const u8,
19 };
20};
21
2212pub fn execute(args: [][]u8) !void {
2313 const url = "https://zpm.random-projects.net/api/packages";
2414
......@@ -30,7 +20,7 @@ pub fn execute(args: [][]u8) !void {
3020
3121 const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));
3222 var stream = std.json.TokenStream.init(body_content);
33 const val = try std.json.parse([]Zpm.Package, &stream, .{ .allocator = gpa });
23 const val = try std.json.parse([]zpm.Package, &stream, .{ .allocator = gpa });
3424
3525 const found = blk: {
3626 for (val) |pkg| {