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 {...@@ -17,6 +17,15 @@ pub const commands = struct {
1717
18pub const server_root = "https://zpm.random-projects.net/api";18pub 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
20pub fn execute(args: [][]u8) !void {29pub fn execute(args: [][]u8) !void {
21 if (args.len == 0) {30 if (args.len == 0) {
22 std.debug.warn("{s}\n", .{31 std.debug.warn("{s}\n", .{
src/cmd/zpm_add.zig+2-12
...@@ -4,21 +4,11 @@ const gpa = std.heap.c_allocator;...@@ -4,21 +4,11 @@ const gpa = std.heap.c_allocator;
4const zfetch = @import("zfetch");4const zfetch = @import("zfetch");
55
6const u = @import("./../util/index.zig");6const u = @import("./../util/index.zig");
7const zpm = @import("./zpm.zig");
78
8//9//
9//10//
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
22pub fn execute(args: [][]u8) !void {12pub fn execute(args: [][]u8) !void {
23 const url = "https://zpm.random-projects.net/api/packages";13 const url = "https://zpm.random-projects.net/api/packages";
2414
...@@ -30,7 +20,7 @@ pub fn execute(args: [][]u8) !void {...@@ -30,7 +20,7 @@ pub fn execute(args: [][]u8) !void {
3020
31 const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));21 const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));
32 var stream = std.json.TokenStream.init(body_content);22 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
35 const found = blk: {25 const found = blk: {
36 for (val) |pkg| {26 for (val) |pkg| {