Be more explicit about device management
This commit is contained in:
parent
82babf0ce6
commit
afc81e3b95
1 changed files with 38 additions and 26 deletions
64
src/main.zig
64
src/main.zig
|
|
@ -413,32 +413,44 @@ pub fn main() !void {
|
||||||
}
|
}
|
||||||
try stdout.flush();
|
try stdout.flush();
|
||||||
|
|
||||||
if (result.devices.len > 0) {
|
switch (result.devices.len) {
|
||||||
const device = result.devices[0];
|
0 => {
|
||||||
|
try stderr.print("❌ No devices found for user\n", .{});
|
||||||
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();
|
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;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue