tangled
alpha
login
or
join now
altagos.dev
/
space
0
fork
atom
A SpaceTraders Agent
0
fork
atom
overview
issues
pulls
pipelines
simple main querying ships
altagos.dev
3 months ago
2a9a563f
961129c8
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+62
-3
2 changed files
expand all
collapse all
unified
split
build.zig
src
main.zig
-1
build.zig
···
66
66
run_step.dependOn(&run_cmd.step);
67
67
68
68
const test_step = b.step("test", "Run tests");
69
69
-
70
69
addTest(b, test_step, "meta tests", meta);
71
70
addTest(b, test_step, "st tests", st);
72
71
addTest(b, test_step, "agent tests", agent);
+62
-2
src/main.zig
···
1
1
const std = @import("std");
2
2
3
3
-
pub fn main() void {
4
4
-
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
3
3
+
const pretty = @import("meta").pretty;
4
4
+
5
5
+
const meta = @import("meta");
6
6
+
7
7
+
const st = @import("st");
8
8
+
const m = st.models;
9
9
+
const Client = st.http.Client;
10
10
+
const RawResponse = st.http.RawResponse;
11
11
+
const Response = st.http.Response;
12
12
+
13
13
+
const Info = st.models.Info;
14
14
+
const agents = st.models.agents;
15
15
+
16
16
+
const agent = @import("agent");
17
17
+
const Config = agent.config.Config;
18
18
+
19
19
+
pub const known_folders_config: @import("known-folders").KnownFolderConfig = .{
20
20
+
.xdg_on_mac = true,
21
21
+
};
22
22
+
23
23
+
fn juicyMain(
24
24
+
gpa: std.mem.Allocator,
25
25
+
io: std.Io,
26
26
+
config: *const Config,
27
27
+
client: *Client,
28
28
+
) !void {
29
29
+
_ = gpa;
30
30
+
_ = config;
31
31
+
// _ = io;
32
32
+
// _ = client;
33
33
+
34
34
+
var fleet_f = try st.fleet.listShips(client, .{});
35
35
+
defer _ = fleet_f.cancel(io) catch {};
36
36
+
37
37
+
const fleet = try fleet_f.await(io);
38
38
+
defer fleet.deinit();
39
39
+
40
40
+
std.log.info("{f}", .{pretty(fleet.value)});
41
41
+
}
42
42
+
43
43
+
pub fn main() !void {
44
44
+
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
45
45
+
defer _ = gpa.deinit();
46
46
+
const allocator = gpa.allocator();
47
47
+
48
48
+
var io_impl: std.Io.Threaded = .init(allocator);
49
49
+
defer io_impl.deinit();
50
50
+
const io = io_impl.io();
51
51
+
52
52
+
std.log.debug("Io threads: {}", .{try io_impl.cpu_count});
53
53
+
54
54
+
const config = try agent.config.load(io, allocator);
55
55
+
defer agent.config.free(allocator, config);
56
56
+
57
57
+
var client = Client.init(allocator, io, .{
58
58
+
.auth = config.auth,
59
59
+
// .base_url = "http://localhost:4000/test",
60
60
+
// .base_url = "https://api.staging.spacetraders.io/v2",
61
61
+
});
62
62
+
defer client.deinit();
63
63
+
64
64
+
try juicyMain(allocator, io, &config, &client);
5
65
}