Skip to content

Commit 985cac4

Browse files
authored
Merge pull request #74 from 00JCIV00/zig-v0.15
Update to Zig v0.15.1
2 parents e8c25e5 + 2b2b595 commit 985cac4

17 files changed

Lines changed: 395 additions & 247 deletions

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Commands **** Options **** Values **** Arguments
44
A simple yet robust cross-platform command line argument parsing library for Zig.
55

6-
[![Static Badge](https://img.shields.io/badge/v0.14.1(stable)-orange?logo=Zig&logoColor=Orange&label=Zig&labelColor=Orange)](https://ziglang.org/download/)
6+
[![Static Badge](https://img.shields.io/badge/v0.15.1(stable)-orange?logo=Zig&logoColor=Orange&label=Zig&labelColor=Orange)](https://ziglang.org/download/)
77
[![Static Badge](https://img.shields.io/badge/v0.10.1b-blue?logo=GitHub&label=Release)](https://github.com/00JCIV00/cova/releases/tag/v0.10.1-beta)
88
[![GitHub commit activity](https://img.shields.io/github/commits-difference/00JCIV00/cova?base=v0.10.1&head=main&logo=Github&label=Commits%20(v0.11.0b))](https://github.com/00JCIV00/cova/commits/main/)
99
[![Static Badge](https://img.shields.io/badge/MIT-silver?label=License)](https://github.com/00JCIV00/cova/blob/main/LICENSE)
@@ -53,11 +53,11 @@ pub fn main() !void {
5353
// ...
5454
var main_cmd = try setup_cmd.init(alloc, .{});
5555
defer main_cmd.deinit();
56-
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
56+
var args_iter: cova.ArgIteratorGeneric = try .init(alloc);
5757
defer args_iter.deinit();
5858
5959
cova.parseArgs(&args_iter, CommandT, main_cmd, stdout, .{}) catch |err| switch (err) {
60-
error.UsageHelpCalled => {},
60+
error.UsageHelpCalled => return,
6161
else => return err,
6262
};
6363
// ...
@@ -185,9 +185,13 @@ pub fn main() !void {
185185
defer main_cmd.deinit();
186186
187187
// Parsing
188-
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
188+
var args_iter: cova.ArgIteratorGeneric = try .init(alloc);
189189
defer args_iter.deinit();
190-
const stdout = std.io.getStdOut().writer();
190+
var stdout_file = fs.File.stdout();
191+
var stdout_buf: [4096]u8 = undefined;
192+
var stdout_writer = stdout_file.writer(stdout_buf[0..]);
193+
const stdout = &stdout_writer.interface;
194+
defer stdout.flush() catch {};
191195
192196
cova.parseArgs(&args_iter, CommandT, main_cmd, stdout, .{}) catch |err| switch (err) {
193197
error.UsageHelpCalled,
@@ -263,8 +267,8 @@ pub fn build(b: *std.Build) void {
263267
264268
const cova_gen = @import("cova").addCovaDocGenStep(b, cova_dep, exe, .{
265269
.kinds = &.{ .all },
266-
.version = "0.10.1",
267-
.ver_date = "25 MAR 2025",
270+
.version = "0.10.2",
271+
.ver_date = "23 AUG 2025",
268272
.author = "00JCIV00",
269273
.copyright = "MIT License",
270274
});

build.zig

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,33 @@ pub fn build(b: *std.Build) void {
1313
const cova_mod = b.addModule("cova", .{
1414
.root_source_file = b.path("src/cova.zig"),
1515
});
16+
// - Meta Module (for Docs and Tests)
17+
const cova_meta_mod = b.addModule("cova", .{
18+
.root_source_file = b.path("src/cova.zig"),
19+
.target = target,
20+
.optimize = optimize,
21+
});
1622
// - Generator Artifact
1723
_ = b.addModule("cova_gen", .{
1824
.root_source_file = b.path("src/generator.zig"),
1925
});
2026

21-
// Static Lib (Used for Docs)
22-
const cova_lib = b.addStaticLibrary(.{
27+
// Library (Used for Docs)
28+
const cova_lib = b.addLibrary(.{
2329
.name = "cova",
24-
.root_source_file = b.path("src/cova.zig"),
25-
.target = target,
26-
.optimize = optimize,
30+
.linkage = .static,
31+
.root_module = cova_meta_mod,
2732
});
28-
//b.installArtifact(cova_lib);
2933

3034
// Tests
31-
const cova_tests = b.addTest(.{
32-
.root_source_file = b.path("src/cova.zig"),
33-
.target = target,
34-
.optimize = optimize,
35-
});
35+
const cova_tests = b.addTest(.{ .root_module = cova_meta_mod });
3636
const run_cova_tests = b.addRunArtifact(cova_tests);
3737
const test_step = b.step("test", "Run the cova library tests");
3838
test_step.dependOn(&run_cova_tests.step);
3939

4040
// Docs
41-
const cova_docs = cova_lib;
42-
//const cova_docs = cova_tests;
4341
const build_docs = b.addInstallDirectory(.{
44-
.source_dir = cova_docs.getEmittedDocs(),
42+
.source_dir = cova_lib.getEmittedDocs(),
4543
.install_dir = .prefix,
4644
.install_subdir = "../docs",
4745
});
@@ -53,7 +51,7 @@ pub fn build(b: *std.Build) void {
5351
// Examples
5452
//==========================================
5553
const examples = &.{ "cova-demo", "basic_app", "logger" };
56-
var ex_arena = std.heap.ArenaAllocator.init(b.allocator);
54+
var ex_arena: std.heap.ArenaAllocator = .init(b.allocator);
5755
defer ex_arena.deinit();
5856
const ex_alloc = ex_arena.allocator();
5957
inline for (examples) |example| {
@@ -63,13 +61,17 @@ pub fn build(b: *std.Build) void {
6361
if (std.mem.eql(u8, example, "cova-demo")) break :exName "covademo";
6462
break :exName example;
6563
};
66-
// - Exe
67-
const ex_exe = b.addExecutable(.{
68-
.name = bin_name orelse ex_name,
64+
// - Mod
65+
const ex_mod = b.createModule(.{
6966
.root_source_file = b.path(std.fmt.allocPrint(ex_alloc, "examples/{s}.zig", .{ ex_name }) catch @panic("OOM")),
7067
.target = target,
7168
.optimize = optimize,
7269
});
70+
// - Exe
71+
const ex_exe = b.addExecutable(.{
72+
.name = bin_name orelse ex_name,
73+
.root_module = ex_mod,
74+
});
7375
ex_exe.root_module.addImport("cova", cova_mod);
7476
const build_ex_demo = b.addInstallArtifact(ex_exe, .{});
7577
const build_ex_demo_step = b.step(example, "Build the '" ++ example ++ "' example (default: Debug)");
@@ -163,21 +165,25 @@ fn createDocGenStep(
163165
doc_gen_config: generate.MetaDocConfig,
164166
) *std.Build.Step.Run {
165167
const program_mod = program_step.root_module;
166-
const cova_gen_exe = b.addExecutable(.{
167-
.name = std.fmt.allocPrint(b.allocator, "cova_generator_{s}", .{ program_step.name }) catch @panic("OOM"),
168+
const cova_gen_mod = b.createModule(.{
168169
.root_source_file = cova_gen_path,
169170
.target = b.graph.host,
170171
.optimize = .Debug,
171172
});
173+
const cova_gen_exe = b.addExecutable(.{
174+
.name = std.fmt.allocPrint(b.allocator, "cova_generator_{s}", .{ program_step.name }) catch @panic("OOM"),
175+
.root_module = cova_gen_mod,
176+
});
172177
b.installArtifact(cova_gen_exe);
173178
cova_gen_exe.root_module.addImport("cova", cova_mod);
174179
cova_gen_exe.root_module.addImport("program", program_mod);
175180

176181
const md_conf_opts = b.addOptions();
177-
var sub_conf_map = std.StringHashMap(?*std.Build.Step.Options).init(b.allocator);
178-
sub_conf_map.put("help_docs_config", null) catch @panic("OOM");
179-
sub_conf_map.put("tab_complete_config", null) catch @panic("OOM");
180-
sub_conf_map.put("arg_template_config", null) catch @panic("OOM");
182+
var sub_conf_map: std.StringHashMapUnmanaged(?*std.Build.Step.Options) = .empty;
183+
defer sub_conf_map.deinit(b.allocator);
184+
sub_conf_map.put(b.allocator, "help_docs_config", null) catch @panic("OOM");
185+
sub_conf_map.put(b.allocator, "tab_complete_config", null) catch @panic("OOM");
186+
sub_conf_map.put(b.allocator, "arg_template_config", null) catch @panic("OOM");
181187

182188
inline for (@typeInfo(generate.MetaDocConfig).@"struct".fields) |field| {
183189
switch(@typeInfo(field.type)) {
@@ -196,7 +202,7 @@ fn createDocGenStep(
196202
doc_conf_opts.addOption(s_field.type, s_field.name, @field(conf, s_field.name));
197203
}
198204
doc_conf_opts.addOption(bool, "provided", true);
199-
sub_conf_map.put(field.name, doc_conf_opts) catch @panic("OOM");
205+
sub_conf_map.put(b.allocator, field.name, doc_conf_opts) catch @panic("OOM");
200206
}
201207
continue;
202208
},
@@ -205,13 +211,14 @@ fn createDocGenStep(
205211
},
206212
.pointer => |ptr| {
207213
if (ptr.child == generate.MetaDocConfig.MetaDocKind) {
208-
var kinds_list = std.ArrayList(usize).init(b.allocator);
214+
var kinds_list: std.ArrayList(usize) = .empty;
215+
defer kinds_list.deinit(b.allocator);
209216
for (@field(doc_gen_config, field.name)) |kind|
210-
kinds_list.append(@intFromEnum(kind)) catch @panic("There was an issue with the Meta Doc Config.");
217+
kinds_list.append(b.allocator, @intFromEnum(kind)) catch @panic("There was an issue with the Meta Doc Config.");
211218
md_conf_opts.addOption(
212219
[]const usize,
213220
field.name,
214-
kinds_list.toOwnedSlice() catch @panic("There was an issue with the Meta Doc Config."),
221+
kinds_list.toOwnedSlice(b.allocator) catch @panic("There was an issue with the Meta Doc Config."),
215222
);
216223
continue;
217224
}

docs/index.html

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
56
<title>Zig Documentation</title>
67
<link rel="icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNTMgMTQwIj48ZyBmaWxsPSIjRjdBNDFEIj48Zz48cG9seWdvbiBwb2ludHM9IjQ2LDIyIDI4LDQ0IDE5LDMwIi8+PHBvbHlnb24gcG9pbnRzPSI0NiwyMiAzMywzMyAyOCw0NCAyMiw0NCAyMiw5NSAzMSw5NSAyMCwxMDAgMTIsMTE3IDAsMTE3IDAsMjIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMzEsOTUgMTIsMTE3IDQsMTA2Ii8+PC9nPjxnPjxwb2x5Z29uIHBvaW50cz0iNTYsMjIgNjIsMzYgMzcsNDQiLz48cG9seWdvbiBwb2ludHM9IjU2LDIyIDExMSwyMiAxMTEsNDQgMzcsNDQgNTYsMzIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMTE2LDk1IDk3LDExNyA5MCwxMDQiLz48cG9seWdvbiBwb2ludHM9IjExNiw5NSAxMDAsMTA0IDk3LDExNyA0MiwxMTcgNDIsOTUiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMTUwLDAgNTIsMTE3IDMsMTQwIDEwMSwyMiIvPjwvZz48Zz48cG9seWdvbiBwb2ludHM9IjE0MSwyMiAxNDAsNDAgMTIyLDQ1Ii8+PHBvbHlnb24gcG9pbnRzPSIxNTMsMjIgMTUzLDExNyAxMDYsMTE3IDEyMCwxMDUgMTI1LDk1IDEzMSw5NSAxMzEsNDUgMTIyLDQ1IDEzMiwzNiAxNDEsMjIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMTI1LDk1IDEzMCwxMTAgMTA2LDExNyIvPjwvZz48L2c+PC9zdmc+">
78
<style type="text/css">
9+
*, *::before, *::after {
10+
box-sizing: border-box;
11+
}
812
body {
913
font-family: system-ui, -apple-system, Roboto, "Segoe UI", sans-serif;
1014
color: #000000;
@@ -26,6 +30,9 @@
2630
margin: 0;
2731
overflow-x: auto;
2832
}
33+
:not(pre) > code {
34+
white-space: break-spaces;
35+
}
2936
code {
3037
font-family:"Source Code Pro",monospace;
3138
font-size: 0.9em;
@@ -153,6 +160,23 @@
153160
cursor: default;
154161
}
155162

163+
#errors {
164+
background-color: #faa;
165+
position: fixed;
166+
left: 0;
167+
bottom: 0;
168+
width: 100%;
169+
max-height: min(20em, 50vh);
170+
padding: 0.5em;
171+
overflow: auto;
172+
}
173+
#errors h1 {
174+
font-size: 1.5em;
175+
}
176+
#errors pre {
177+
background-color: #fcc;
178+
}
179+
156180
#listSearchResults li.selected {
157181
background-color: #93e196;
158182
}
@@ -167,7 +191,8 @@
167191
margin-top: 0.5em;
168192
}
169193

170-
td {
194+
td, th {
195+
text-align: unset;
171196
vertical-align: top;
172197
margin: 0;
173198
padding: 0.5em;
@@ -247,6 +272,14 @@
247272
#listSearchResults li.selected a {
248273
color: #fff;
249274
}
275+
#errors {
276+
background-color: #800;
277+
color: #fff;
278+
}
279+
#errors pre {
280+
background-color: #a00;
281+
color: #fff;
282+
}
250283
dl > div {
251284
border-color: #373737;
252285
}
@@ -409,6 +442,10 @@ <h1>Keyboard Shortcuts</h1>
409442
<dl><dt><kbd></kbd></dt><dd>Move down in search results</dd></dl>
410443
<dl><dt><kbd></kbd></dt><dd>Go to active search result</dd></dl>
411444
</div>
445+
<div id="errors" class="hidden">
446+
<h1>Errors</h1>
447+
<pre id="errorsText"></pre>
448+
</div>
412449
<script src="main.js"></script>
413450
</body>
414451
</html>

0 commit comments

Comments
 (0)