| ... | ... | @@ -119,6 +119,8 @@ pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: |
| 119 | 119 | out.print(" {},\n", .{std.zig.fmtId(field.name)}) catch unreachable; |
| 120 | 120 | } |
| 121 | 121 | out.writeAll("};\n") catch unreachable; |
| 122 | out.print("pub const {}: {s} = {s}.{s};\n", .{ std.zig.fmtId(name), @typeName(T), @typeName(T), std.zig.fmtId(@tagName(value)) }) catch unreachable; |
| 123 | return; |
| 122 | 124 | }, |
| 123 | 125 | else => {}, |
| 124 | 126 | } |
| ... | ... | @@ -236,10 +238,15 @@ test "OptionsStep" { |
| 236 | 238 | |
| 237 | 239 | const options = builder.addOptions(); |
| 238 | 240 | |
| 241 | const KeywordEnum = enum { |
| 242 | @"0.8.1", |
| 243 | }; |
| 244 | |
| 239 | 245 | options.addOption(usize, "option1", 1); |
| 240 | 246 | options.addOption(?usize, "option2", null); |
| 241 | 247 | options.addOption([]const u8, "string", "zigisthebest"); |
| 242 | 248 | options.addOption(?[]const u8, "optional_string", null); |
| 249 | options.addOption(KeywordEnum, "keyword_enum", .@"0.8.1"); |
| 243 | 250 | options.addOption(std.builtin.Version, "version", try std.builtin.Version.parse("0.1.2")); |
| 244 | 251 | options.addOption(std.SemanticVersion, "semantic_version", try std.SemanticVersion.parse("0.1.2-foo+bar")); |
| 245 | 252 | |
| ... | ... | @@ -248,6 +255,10 @@ test "OptionsStep" { |
| 248 | 255 | \\pub const option2: ?usize = null; |
| 249 | 256 | \\pub const string: []const u8 = "zigisthebest"; |
| 250 | 257 | \\pub const optional_string: ?[]const u8 = null; |
| 258 | \\pub const KeywordEnum = enum { |
| 259 | \\ @"0.8.1", |
| 260 | \\}; |
| 261 | \\pub const keyword_enum: KeywordEnum = KeywordEnum.@"0.8.1"; |
| 251 | 262 | \\pub const version: @import("std").builtin.Version = .{ |
| 252 | 263 | \\ .major = 0, |
| 253 | 264 | \\ .minor = 1, |