Fixed arguments statement
This commit is contained in:
parent
c3a468d090
commit
e45599e9ec
2 changed files with 12 additions and 5 deletions
10
src/main.zig
10
src/main.zig
|
@ -14,9 +14,11 @@ pub fn main() !void {
|
||||||
|
|
||||||
const args = try std.process.argsAlloc(allocator);
|
const args = try std.process.argsAlloc(allocator);
|
||||||
defer std.process.argsFree(allocator, args);
|
defer std.process.argsFree(allocator, args);
|
||||||
|
|
||||||
if (eql(u8, args[1], "help")) {
|
if (args.len > 1) {
|
||||||
dbg_print("Help :)\n", .{});
|
if (eql(u8, args[1], "help")) {
|
||||||
|
dbg_print("Help :)\n", .{});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = try url.fetch(allocator, "https://tidal.401658.xyz/track/?id=286266927&quality=LOSSLESS");
|
const data = try url.fetch(allocator, "https://tidal.401658.xyz/track/?id=286266927&quality=LOSSLESS");
|
||||||
|
@ -24,4 +26,4 @@ pub fn main() !void {
|
||||||
|
|
||||||
try json.extract(allocator, data);
|
try json.extract(allocator, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
const dbg_print = std.debug.print;
|
const dbg_print = std.debug.print;
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +25,10 @@ pub fn fetch(allocator: std.mem.Allocator, url: []const u8) ![]u8 {
|
||||||
|
|
||||||
const body = try req.reader().readAllAlloc(allocator, 1024 * 64);
|
const body = try req.reader().readAllAlloc(allocator, 1024 * 64);
|
||||||
|
|
||||||
return body;
|
if (req.response.status == .ok) {
|
||||||
|
return body;
|
||||||
|
}else{
|
||||||
|
return error.Unexpected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue