Changes
4 changed files (+67/-13)
-
-
@@ -29,9 +29,8 @@ twilight_angle: f64 = c.TWILIGHT_ANGLE_DAYLIGHT,target_time: ?c.time_t = null, utc: bool = false, debug: bool = false, report_sunrise: c.OnOff = c.ONOFF_OFF, report_sunset: c.OnOff = c.ONOFF_OFF, list_days: c_uint = c.DEFAULT_LIST, report_sunrise: c.OnOff = c.ONOFF_ON, report_sunset: c.OnOff = c.ONOFF_ON, utc_bias_hours: f64 = 0, command: CommandOptions = .poll,
-
@@ -43,12 +42,13 @@ InvalidLongitudeFormat,}; pub const ListOptions = struct { days: c_uint = 1, days: c_uint = c.DEFAULT_LIST, pub fn parseArg(self: *@This(), arg: []const u8, args: *std.process.ArgIterator) ParseArgsError!void { _ = self; _ = arg; _ = args; pub fn parseArg(self: *@This(), arg: []const u8, _: *std.process.ArgIterator) ParseArgsError!void { if (std.fmt.parseUnsigned(c_uint, arg, 10)) |days| { self.days = days; return; } else |_| {} return ParseArgsError.UnknownArg; }
-
@@ -315,7 +315,10 @@ .utc = if (self.utc) c.ONOFF_ON else c.ONOFF_OFF,.debug = if (self.debug) c.ONOFF_ON else c.ONOFF_OFF, .reportSunrise = self.report_sunrise, .reportSunset = self.report_sunset, .listDays = self.list_days, .listDays = switch (self.command) { .list => |opts| opts.days, else => c.DEFAULT_LIST, }, .utcBiasHours = self.utc_bias_hours, }; }
-
-
-
@@ -157,10 +157,11 @@ return ExitCode.generic_error.code();}, } }, .list => |command_opts| { _ = command_opts; std.log.err("list command is not implemented", .{}); return ExitCode.generic_error.code(); .list => |_| { var c_opts = opts.toC(); c.print_list(&c_opts); return ExitCode.ok.code(); }, .report => { std.log.err("report command is not implemented", .{});
-
-
tests/list.zig (new)
-
@@ -0,0 +1,49 @@// Copyright (C) 2025 Shota FUJI // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. // // SPDX-License-Identifier: GPL-3.0-only const std = @import("std"); const config = @import("config"); fn list(allocator: std.mem.Allocator, bin: []const u8) !std.process.Child.RunResult { var env = std.process.EnvMap.init(allocator); defer env.deinit(); try env.put("TZ", "UTC"); return try std.process.Child.run(.{ .allocator = allocator, .argv = &.{ bin, "list", "3", "29.977435N", "31.132484E" }, .env_map = &env, }); } test { const legacy = try list(std.testing.allocator, config.legacy_bin); defer std.testing.allocator.free(legacy.stderr); defer std.testing.allocator.free(legacy.stdout); const new = try list(std.testing.allocator, config.new_bin); defer std.testing.allocator.free(new.stderr); defer std.testing.allocator.free(new.stdout); try std.testing.expectEqual(legacy.term.Exited, new.term.Exited); return error.SkipZigTest; // TODO: Uncomment these once correct handling of "target_time" is implemented. // try std.testing.expectEqualStrings(legacy.stderr, new.stderr); // try std.testing.expectEqualStrings(legacy.stdout, new.stdout); }
-
-
-
@@ -18,6 +18,7 @@comptime { _ = @import("./report.zig"); _ = @import("./poll.zig"); _ = @import("./list.zig"); _ = @import("./help.zig"); _ = @import("./version.zig"); }
-