Skip to content

Commit 2c61784

Browse files
chore: wip
1 parent b0bc2d1 commit 2c61784

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/cli/Middleware.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ pub fn loggingMiddleware(ctx: *MiddlewareContext) !bool {
112112

113113
/// Timing middleware
114114
pub fn timingMiddleware(ctx: *MiddlewareContext) !bool {
115-
const start = std.time.milliTimestamp();
115+
const start = blk: {
116+
var ts: std.c.timespec = .{ .sec = 0, .nsec = 0 };
117+
_ = std.c.clock_gettime(std.c.CLOCK.REALTIME, &ts);
118+
break :blk @as(i64, ts.sec) * 1000 + @as(i64, @intCast(@divTrunc(ts.nsec, std.time.ns_per_ms)));
119+
};
116120
try ctx.set("start_time", try std.fmt.allocPrint(ctx.allocator, "{d}", .{start}));
117121
return true;
118122
}

src/prompt/PathPrompt.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ pub fn prompt(self: *PathPrompt) ![]const u8 {
6262
continue;
6363
}
6464

65-
std.time.sleep(10 * std.time.ns_per_ms);
65+
{
66+
var ts: std.c.timespec = .{ .sec = 0, .nsec = 10 * std.time.ns_per_ms };
67+
_ = std.c.nanosleep(&ts, null);
68+
}
6669
}
6770

6871
try self.core.finish();

src/prompt/Table.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ pub const Alignment = enum {
1111
};
1212

1313
pub const TableStyle = enum {
14-
simple, // Simple ASCII
15-
rounded, // Rounded corners
16-
double, // Double lines
17-
minimal, // Minimal borders
14+
simple, // Simple ASCII
15+
rounded, // Rounded corners
16+
double, // Double lines
17+
minimal, // Minimal borders
1818
};
1919

2020
pub const Column = struct {
@@ -47,7 +47,7 @@ pub fn deinit(self: *Table) void {
4747
for (self.rows.items) |row| {
4848
self.allocator.free(row);
4949
}
50-
self.rows.deinit();
50+
self.rows.deinit(self.allocator);
5151
}
5252

5353
pub fn withStyle(self: Table, style: TableStyle) Table {
@@ -62,7 +62,7 @@ pub fn addRow(self: *Table, row: []const []const u8) !void {
6262
}
6363

6464
const row_copy = try self.allocator.dupe([]const u8, row);
65-
try self.rows.append(row_copy);
65+
try self.rows.append(self.allocator, row_copy);
6666
}
6767

6868
pub fn render(self: *Table) !void {

0 commit comments

Comments
 (0)