const std = @import("std"); var x_auth_token: ?[:0]const u8 = undefined; var x_auth_email: ?[:0]const u8 = undefined; var x_auth_key: ?[:0]const u8 = undefined; var initialized = false; const cf_api_base = "https://api.cloudflare.com/client/v4"; pub fn main() !u8 { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); var client = std.http.Client{ .allocator = allocator }; defer client.deinit(); var proxy_text = std.os.getenv("https_proxy") orelse std.os.getenv("HTTPS_PROXY"); if (proxy_text) |p| { client.deinit(); const proxy = try std.Uri.parse(p); client = std.http.Client{ .allocator = allocator, .proxy = .{ .protocol = if (std.ascii.eqlIgnoreCase(proxy.scheme, "http")) .plain else .tls, .host = proxy.host.?, .port = proxy.port, }, }; } const stdout_file = std.io.getStdOut().writer(); var bw = std.io.bufferedWriter(stdout_file); const stdout = bw.writer(); var argIterator = try std.process.argsWithAllocator(allocator); defer argIterator.deinit(); const exe_name = argIterator.next().?; var maybe_name = argIterator.next(); if (maybe_name == null) { try usage(std.io.getStdErr().writer(), exe_name); return 1; } const worker_name = maybe_name.?; if (std.mem.eql(u8, worker_name, "-h")) { try usage(stdout, exe_name); return 0; } var maybe_script_name = argIterator.next(); if (maybe_script_name == null) { try usage(std.io.getStdErr().writer(), exe_name); return 1; } const script = std.fs.cwd().readFileAlloc(allocator, maybe_script_name.?, std.math.maxInt(usize)) catch |err| { try usage(std.io.getStdErr().writer(), exe_name); return err; }; pushWorker(allocator, &client, worker_name, script, ".", stdout, std.io.getStdErr().writer()) catch return 1; try bw.flush(); // don't forget to flush! return 0; } fn usage(writer: anytype, this: []const u8) !void { try writer.print("usage: {s}