Be more explicit about device management

This commit is contained in:
Emil Lerch 2025-12-09 13:48:40 -08:00
parent 82babf0ce6
commit afc81e3b95
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -413,32 +413,44 @@ pub fn main() !void {
}
try stdout.flush();
if (result.devices.len > 0) {
const device = result.devices[0];
if (device.serial_id) |sid| {
try stdout.print("🔍 Checking recirculation status for {?s}...\n", .{device.device_name});
try stdout.flush();
var status = try getRecirculationStatus(allocator, auth.id_token, sid);
defer status.deinit();
try stdout.print("\n{f}", .{status});
const recirc_enabled = status.recirculation_enabled orelse false;
if (recirc_enabled) {
try stdout.print("\n✓ Recirculation is already active\n", .{});
// Recirculation code commented out as requested
} else {
// Recirculation code would go here but not called during testing
try stdout.print("\n(Recirculation start function available but not called during testing)\n", .{});
}
try stdout.flush();
} else {
try stderr.print("❌ No serial_id found for device\n", .{});
switch (result.devices.len) {
0 => {
try stderr.print("❌ No devices found for user\n", .{});
try stderr.flush();
return error.NoSerialId;
}
return error.NoDevicesFound;
},
1 => {
const device = result.devices[0];
if (device.serial_id) |sid| {
try stdout.print("🔍 Checking recirculation status for {?s}...\n", .{device.device_name});
try stdout.flush();
var status = try getRecirculationStatus(allocator, auth.id_token, sid);
defer status.deinit();
try stdout.print("\n{f}", .{status});
const recirc_enabled = status.recirculation_enabled orelse false;
if (recirc_enabled) {
try stdout.print("\n✓ Recirculation is already active\n", .{});
// Recirculation code commented out as requested
} else {
// Recirculation code would go here but not called during testing
try stdout.print("\n(Recirculation start function available but not called during testing)\n", .{});
}
try stdout.flush();
} else {
try stderr.print("❌ No serial_id found for device\n", .{});
try stderr.flush();
return error.NoSerialId;
}
},
else => {
try stderr.print("❌ More than one device found for user, not currently equipped to handle this\n", .{});
try stderr.flush();
return error.TooManyDevicesFound;
},
}
}