authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 01:24:06 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 01:24:06 -07:00
logd6b9e2e2c4b96f8191817f54deda3c5fbb7c45c5
treee54df6f3fe38c538ae82bbe8f3eeea3e0d4b30ab
parent23a2a9d5567665799589d2ca41583da2f5e0f716

use new json api to clean up optional usage


6 files changed, 21 insertions(+), 15 deletions(-)

deps.zig+9-4
...@@ -52,6 +52,7 @@ const dirs = struct {...@@ -52,6 +52,7 @@ const dirs = struct {
52 pub const _yyhw90zkzgmu = cache ++ "/git/github.com/MasterQ32/zig-network";52 pub const _yyhw90zkzgmu = cache ++ "/git/github.com/MasterQ32/zig-network";
53 pub const _u9w9dpp6p804 = cache ++ "/git/github.com/MasterQ32/zig-uri";53 pub const _u9w9dpp6p804 = cache ++ "/git/github.com/MasterQ32/zig-uri";
54 pub const _ocmr9rtohgcc = cache ++ "/git/github.com/nektro/zig-json";54 pub const _ocmr9rtohgcc = cache ++ "/git/github.com/nektro/zig-json";
55 pub const _f7dubzb7cyqe = cache ++ "/git/github.com/nektro/zig-extras";
55 pub const _tnj3qf44tpeq = cache ++ "/git/github.com/nektro/zig-range";56 pub const _tnj3qf44tpeq = cache ++ "/git/github.com/nektro/zig-range";
56 pub const _2ovav391ivak = cache ++ "/git/github.com/nektro/zig-detect-license";57 pub const _2ovav391ivak = cache ++ "/git/github.com/nektro/zig-detect-license";
57 pub const _pt88y5d80m25 = cache ++ "/git/github.com/nektro/zig-licenses-text";58 pub const _pt88y5d80m25 = cache ++ "/git/github.com/nektro/zig-licenses-text";
...@@ -101,14 +102,18 @@ pub const package_data = struct {...@@ -101,14 +102,18 @@ pub const package_data = struct {
101 .directory = dirs._ejw82j2ipa0e,102 .directory = dirs._ejw82j2ipa0e,
102 .pkg = Pkg{ .name = "zfetch", .path = .{ .path = dirs._ejw82j2ipa0e ++ "/src/main.zig" }, .dependencies = &.{ _9k24gimke1an.pkg.?, _csbnipaad8n7.pkg.?, _yyhw90zkzgmu.pkg.?, _u9w9dpp6p804.pkg.? } },103 .pkg = Pkg{ .name = "zfetch", .path = .{ .path = dirs._ejw82j2ipa0e ++ "/src/main.zig" }, .dependencies = &.{ _9k24gimke1an.pkg.?, _csbnipaad8n7.pkg.?, _yyhw90zkzgmu.pkg.?, _u9w9dpp6p804.pkg.? } },
103 };104 };
104 pub const _ocmr9rtohgcc = Package{
105 .directory = dirs._ocmr9rtohgcc,
106 .pkg = Pkg{ .name = "json", .path = .{ .path = dirs._ocmr9rtohgcc ++ "/src/lib.zig" }, .dependencies = null },
107 };
108 pub const _tnj3qf44tpeq = Package{105 pub const _tnj3qf44tpeq = Package{
109 .directory = dirs._tnj3qf44tpeq,106 .directory = dirs._tnj3qf44tpeq,
110 .pkg = Pkg{ .name = "range", .path = .{ .path = dirs._tnj3qf44tpeq ++ "/src/lib.zig" }, .dependencies = null },107 .pkg = Pkg{ .name = "range", .path = .{ .path = dirs._tnj3qf44tpeq ++ "/src/lib.zig" }, .dependencies = null },
111 };108 };
109 pub const _f7dubzb7cyqe = Package{
110 .directory = dirs._f7dubzb7cyqe,
111 .pkg = Pkg{ .name = "extras", .path = .{ .path = dirs._f7dubzb7cyqe ++ "/src/lib.zig" }, .dependencies = &.{ _tnj3qf44tpeq.pkg.? } },
112 };
113 pub const _ocmr9rtohgcc = Package{
114 .directory = dirs._ocmr9rtohgcc,
115 .pkg = Pkg{ .name = "json", .path = .{ .path = dirs._ocmr9rtohgcc ++ "/src/lib.zig" }, .dependencies = &.{ _f7dubzb7cyqe.pkg.? } },
116 };
112 pub const _pt88y5d80m25 = Package{117 pub const _pt88y5d80m25 = Package{
113 .directory = dirs._pt88y5d80m25,118 .directory = dirs._pt88y5d80m25,
114 .pkg = Pkg{ .name = "licenses-text", .path = .{ .path = dirs._pt88y5d80m25 ++ "/src/lib.zig" }, .dependencies = null },119 .pkg = Pkg{ .name = "licenses-text", .path = .{ .path = dirs._pt88y5d80m25 ++ "/src/lib.zig" }, .dependencies = null },
src/cmd/aq.zig+2-2
...@@ -57,8 +57,8 @@ pub fn server_fetch(url: string) !json.Value {...@@ -57,8 +57,8 @@ pub fn server_fetch(url: string) !json.Value {
57 const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));57 const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));
58 const val = try json.parse(gpa, body_content);58 const val = try json.parse(gpa, body_content);
5959
60 if (val.get("message")) |msg| {60 if (val.getT("message", .String)) |msg| {
61 std.log.err("server: {s}", .{msg.String});61 std.log.err("server: {s}", .{msg});
62 return error.AquilaBadResponse;62 return error.AquilaBadResponse;
63 }63 }
64 return val;64 return val;
src/cmd/aquila/add.zig+2-2
...@@ -19,8 +19,8 @@ pub fn do(dir: std.fs.Dir, pkg_id: string) !string {...@@ -19,8 +19,8 @@ pub fn do(dir: std.fs.Dir, pkg_id: string) !string {
19 const val = try aq.server_fetch(url);19 const val = try aq.server_fetch(url);
2020
21 const pkg_url = try std.fmt.allocPrint(gpa, "https://{s}/{s}", .{21 const pkg_url = try std.fmt.allocPrint(gpa, "https://{s}/{s}", .{
22 val.get(.{ "repo", "domain" }).?.String,22 val.getT(.{ "repo", "domain" }, .String).?,
23 val.get(.{ "pkg", "RemoteName" }).?.String,23 val.getT(.{ "pkg", "RemoteName" }, .String).?,
24 });24 });
2525
26 const m = try u.ModFile.from_dir(gpa, dir);26 const m = try u.ModFile.from_dir(gpa, dir);
src/cmd/zpm/search.zig+3-3
...@@ -27,9 +27,9 @@ pub fn execute(args: [][]u8) !void {...@@ -27,9 +27,9 @@ pub fn execute(args: [][]u8) !void {
27 continue;27 continue;
28 }28 }
29 try arr.append(zpm.Package{29 try arr.append(zpm.Package{
30 .name = item.get("name").?.String,30 .name = item.getT("name", .String).?,
31 .author = item.get("author").?.String,31 .author = item.getT("author", .String).?,
32 .description = item.get("description").?.String,32 .description = item.getT("description", .String).?,
33 .tags = &.{},33 .tags = &.{},
34 .git = "",34 .git = "",
35 .root_file = "",35 .root_file = "",
src/cmd/zpm/tags.zig+3-3
...@@ -22,7 +22,7 @@ pub fn execute(args: [][]u8) !void {...@@ -22,7 +22,7 @@ pub fn execute(args: [][]u8) !void {
22 const name_col_width = blk: {22 const name_col_width = blk: {
23 var w: usize = 4;23 var w: usize = 4;
24 for (val.Array) |tag| {24 for (val.Array) |tag| {
25 const len = tag.get("name").?.String.len;25 const len = tag.getT("name", .String).?.len;
26 if (len > w) {26 if (len > w) {
27 w = len;27 w = len;
28 }28 }
...@@ -35,10 +35,10 @@ pub fn execute(args: [][]u8) !void {...@@ -35,10 +35,10 @@ pub fn execute(args: [][]u8) !void {
35 try out.writeAll("DESCRIPTION\n");35 try out.writeAll("DESCRIPTION\n");
3636
37 for (val.Array) |tag| {37 for (val.Array) |tag| {
38 const name = tag.get("name").?.String;38 const name = tag.getT("name", .String).?;
39 try out.writeAll(name);39 try out.writeAll(name);
40 try print_c_n(out, ' ', name_col_width - name.len);40 try print_c_n(out, ' ', name_col_width - name.len);
41 try out.writeAll(tag.get("description").?.String);41 try out.writeAll(tag.getT("description", .String).?);
42 try out.writeAll("\n");42 try out.writeAll("\n");
43 }43 }
44}44}
zigmod.lock+2-1
...@@ -8,7 +8,8 @@ git https://github.com/truemedian/zfetch commit-77fdd34e90db02f1224cdc7e5231ecd0...@@ -8,7 +8,8 @@ git https://github.com/truemedian/zfetch commit-77fdd34e90db02f1224cdc7e5231ecd0
8git https://github.com/truemedian/hzzp commit-91ab8e741992e8db30b3ee1cd9e7cd5a072ca2948git https://github.com/truemedian/hzzp commit-91ab8e741992e8db30b3ee1cd9e7cd5a072ca294
9git https://github.com/MasterQ32/zig-network commit-0439bd7127ecb8f927a5cecb0beeb1569db2fb959git https://github.com/MasterQ32/zig-network commit-0439bd7127ecb8f927a5cecb0beeb1569db2fb95
10git https://github.com/MasterQ32/zig-uri commit-52cdd2061bec0579519f0d30280597f3a1db8b7510git https://github.com/MasterQ32/zig-uri commit-52cdd2061bec0579519f0d30280597f3a1db8b75
11git https://github.com/nektro/zig-json commit-3ea23e8ae3798d3929b4c4b54ce739a67914f3ec11git https://github.com/nektro/zig-json commit-7f0e661371d41cfdc8b1649ed00e7a750c82e57a
12git https://github.com/nektro/zig-extras commit-090ee5f1834af4ed7714101b24d7daec84572390
12git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95dbf939f13git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95dbf939f
13git https://github.com/nektro/zig-detect-license commit-d4544410f811c402b866f21f63588d1aae1b2d9014git https://github.com/nektro/zig-detect-license commit-d4544410f811c402b866f21f63588d1aae1b2d90
14git https://github.com/nektro/zig-licenses-text commit-3c07c6e4eb0965dafd0b029c632f823631b3169c15git https://github.com/nektro/zig-licenses-text commit-3c07c6e4eb0965dafd0b029c632f823631b3169c