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 {
5252 pub const _yyhw90zkzgmu = cache ++ "/git/github.com/MasterQ32/zig-network";
5353 pub const _u9w9dpp6p804 = cache ++ "/git/github.com/MasterQ32/zig-uri";
5454 pub const _ocmr9rtohgcc = cache ++ "/git/github.com/nektro/zig-json";
55 pub const _f7dubzb7cyqe = cache ++ "/git/github.com/nektro/zig-extras";
5556 pub const _tnj3qf44tpeq = cache ++ "/git/github.com/nektro/zig-range";
5657 pub const _2ovav391ivak = cache ++ "/git/github.com/nektro/zig-detect-license";
5758 pub const _pt88y5d80m25 = cache ++ "/git/github.com/nektro/zig-licenses-text";
......@@ -101,14 +102,18 @@ pub const package_data = struct {
101102 .directory = dirs._ejw82j2ipa0e,
102103 .pkg = Pkg{ .name = "zfetch", .path = .{ .path = dirs._ejw82j2ipa0e ++ "/src/main.zig" }, .dependencies = &.{ _9k24gimke1an.pkg.?, _csbnipaad8n7.pkg.?, _yyhw90zkzgmu.pkg.?, _u9w9dpp6p804.pkg.? } },
103104 };
104 pub const _ocmr9rtohgcc = Package{
105 .directory = dirs._ocmr9rtohgcc,
106 .pkg = Pkg{ .name = "json", .path = .{ .path = dirs._ocmr9rtohgcc ++ "/src/lib.zig" }, .dependencies = null },
107 };
108105 pub const _tnj3qf44tpeq = Package{
109106 .directory = dirs._tnj3qf44tpeq,
110107 .pkg = Pkg{ .name = "range", .path = .{ .path = dirs._tnj3qf44tpeq ++ "/src/lib.zig" }, .dependencies = null },
111108 };
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 };
112117 pub const _pt88y5d80m25 = Package{
113118 .directory = dirs._pt88y5d80m25,
114119 .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 {
5757 const body_content = try r.readAllAlloc(gpa, std.math.maxInt(usize));
5858 const val = try json.parse(gpa, body_content);
5959
60 if (val.get("message")) |msg| {
61 std.log.err("server: {s}", .{msg.String});
60 if (val.getT("message", .String)) |msg| {
61 std.log.err("server: {s}", .{msg});
6262 return error.AquilaBadResponse;
6363 }
6464 return val;
src/cmd/aquila/add.zig+2-2
......@@ -19,8 +19,8 @@ pub fn do(dir: std.fs.Dir, pkg_id: string) !string {
1919 const val = try aq.server_fetch(url);
2020
2121 const pkg_url = try std.fmt.allocPrint(gpa, "https://{s}/{s}", .{
22 val.get(.{ "repo", "domain" }).?.String,
23 val.get(.{ "pkg", "RemoteName" }).?.String,
22 val.getT(.{ "repo", "domain" }, .String).?,
23 val.getT(.{ "pkg", "RemoteName" }, .String).?,
2424 });
2525
2626 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 {
2727 continue;
2828 }
2929 try arr.append(zpm.Package{
30 .name = item.get("name").?.String,
31 .author = item.get("author").?.String,
32 .description = item.get("description").?.String,
30 .name = item.getT("name", .String).?,
31 .author = item.getT("author", .String).?,
32 .description = item.getT("description", .String).?,
3333 .tags = &.{},
3434 .git = "",
3535 .root_file = "",
src/cmd/zpm/tags.zig+3-3
......@@ -22,7 +22,7 @@ pub fn execute(args: [][]u8) !void {
2222 const name_col_width = blk: {
2323 var w: usize = 4;
2424 for (val.Array) |tag| {
25 const len = tag.get("name").?.String.len;
25 const len = tag.getT("name", .String).?.len;
2626 if (len > w) {
2727 w = len;
2828 }
......@@ -35,10 +35,10 @@ pub fn execute(args: [][]u8) !void {
3535 try out.writeAll("DESCRIPTION\n");
3636
3737 for (val.Array) |tag| {
38 const name = tag.get("name").?.String;
38 const name = tag.getT("name", .String).?;
3939 try out.writeAll(name);
4040 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).?);
4242 try out.writeAll("\n");
4343 }
4444}
zigmod.lock+2-1
......@@ -8,7 +8,8 @@ git https://github.com/truemedian/zfetch commit-77fdd34e90db02f1224cdc7e5231ecd0
88git https://github.com/truemedian/hzzp commit-91ab8e741992e8db30b3ee1cd9e7cd5a072ca294
99git https://github.com/MasterQ32/zig-network commit-0439bd7127ecb8f927a5cecb0beeb1569db2fb95
1010git https://github.com/MasterQ32/zig-uri commit-52cdd2061bec0579519f0d30280597f3a1db8b75
11git https://github.com/nektro/zig-json commit-3ea23e8ae3798d3929b4c4b54ce739a67914f3ec
11git https://github.com/nektro/zig-json commit-7f0e661371d41cfdc8b1649ed00e7a750c82e57a
12git https://github.com/nektro/zig-extras commit-090ee5f1834af4ed7714101b24d7daec84572390
1213git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95dbf939f
1314git https://github.com/nektro/zig-detect-license commit-d4544410f811c402b866f21f63588d1aae1b2d90
1415git https://github.com/nektro/zig-licenses-text commit-3c07c6e4eb0965dafd0b029c632f823631b3169c