A SpaceTraders Agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at e8f6f30d34ae24601ed30306e9b21ff44cd188df 65 lines 1.6 kB view raw
1const std = @import("std"); 2 3const pretty = @import("meta").pretty; 4 5const meta = @import("meta"); 6 7const st = @import("st"); 8const m = st.models; 9const Client = st.http.Client; 10const RawResponse = st.http.RawResponse; 11const Response = st.http.Response; 12 13const Info = st.models.Info; 14const agents = st.models.agents; 15 16const agent = @import("agent"); 17const Config = agent.config.Config; 18 19pub const known_folders_config: @import("known-folders").KnownFolderConfig = .{ 20 .xdg_on_mac = true, 21}; 22 23fn juicyMain( 24 gpa: std.mem.Allocator, 25 io: std.Io, 26 config: *const Config, 27 client: *Client, 28) !void { 29 _ = gpa; 30 _ = config; 31 // _ = io; 32 // _ = client; 33 34 var fleet_f = try st.fleet.listShips(client, .{}); 35 defer _ = fleet_f.cancel(io) catch {}; 36 37 const fleet = try fleet_f.await(io); 38 defer fleet.deinit(); 39 40 std.log.info("{f}", .{pretty(fleet.value)}); 41} 42 43pub fn main() !void { 44 var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 45 defer _ = gpa.deinit(); 46 const allocator = gpa.allocator(); 47 48 var io_impl: std.Io.Threaded = .init(allocator); 49 defer io_impl.deinit(); 50 const io = io_impl.io(); 51 52 std.log.debug("Io threads: {}", .{io_impl.concurrent_limit.toInt() orelse 0}); 53 54 const config = try agent.config.load(io, allocator); 55 defer agent.config.free(allocator, config); 56 57 var client = Client.init(allocator, io, .{ 58 .auth = config.auth, 59 // .base_url = "http://localhost:4000/test", 60 // .base_url = "https://api.staging.spacetraders.io/v2", 61 }); 62 defer client.deinit(); 63 64 try juicyMain(allocator, io, &config, &client); 65}