Skip to content

Commit cb063f6

Browse files
committed
Cleanup code fmt
1 parent 7e8e0f3 commit cb063f6

4 files changed

Lines changed: 121 additions & 121 deletions

File tree

src/commands.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ fn repeatByte(allocator: std.mem.Allocator, byte: u8, count: usize) ![]u8 {
2424
pub fn displayHelpData(alloc: std.mem.Allocator) !void {
2525
const message = "Welcome to Zippy!";
2626
const boxWidth: usize = message.len + 4;
27-
const dash_count = boxWidth - 2;
27+
const dashCount = boxWidth - 2;
2828

29-
const lineBytes = try alloc.alloc(u8, dash_count * 3);
29+
const lineBytes = try alloc.alloc(u8, dashCount * 3);
3030
defer alloc.free(lineBytes);
31-
for (0..dash_count) |i| {
31+
for (0..dashCount) |i| {
3232
const offset = i * 3;
3333
lineBytes[offset + 0] = 0xE2;
3434
lineBytes[offset + 1] = 0x94;
3535
lineBytes[offset + 2] = 0x80;
3636
}
3737
const line = lineBytes;
3838

39-
const padding_count = (boxWidth - message.len - 1) / 2;
40-
const padding = try repeatByte(alloc, ' ', padding_count);
39+
const paddingCount = (boxWidth - message.len - 1) / 2;
40+
const padding = try repeatByte(alloc, ' ', paddingCount);
4141
defer alloc.free(padding);
4242

4343
try printFmt("{s}┌{s}┐\n", .{ Colors.red, line });

src/logger.zig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const c = @cImport({
1515
pub const Logger = struct {
1616
alloc: std.mem.Allocator,
1717
name: []const u8 = "zippy",
18-
use_color: bool = true,
18+
useColor: bool = true,
1919
file: ?std.fs.File = null,
20-
log_path: ?[]const u8 = null,
20+
logPath: ?[]const u8 = null,
2121
mutex: std.Thread.Mutex = .{},
2222

2323
// ANSI
@@ -29,32 +29,32 @@ pub const Logger = struct {
2929
const Cyan = "\x1b[36m";
3030

3131
pub fn init(alloc: std.mem.Allocator, name: []const u8) Logger {
32-
const stderr_is_tty = std.posix.isatty(std.fs.File.stderr().handle);
32+
const stderrIsTty = std.posix.isatty(std.fs.File.stderr().handle);
3333
return .{
3434
.alloc = alloc,
3535
.name = name,
36-
.use_color = stderr_is_tty,
36+
.useColor = stderrIsTty,
3737
.file = null,
38-
.log_path = null,
38+
.logPath = null,
3939
};
4040
}
4141

4242
pub fn enableFileLogging(self: *Logger, path: []const u8) !void {
4343
const file = try std.fs.cwd().createFile(path, .{ .read = true, .truncate = false, .exclusive = false, .mode = 0o644 });
4444
try file.seekFromEnd(0);
4545
self.file = file;
46-
self.log_path = try self.alloc.dupe(u8, path);
46+
self.logPath = try self.alloc.dupe(u8, path);
4747
}
4848

4949
pub fn deinit(self: *Logger) void {
5050
if (self.file) |f| f.close();
5151
self.file = null;
52-
if (self.log_path) |p| self.alloc.free(p);
53-
self.log_path = null;
52+
if (self.logPath) |p| self.alloc.free(p);
53+
self.logPath = null;
5454
}
5555

5656
pub fn setColor(self: *Logger, enabled: bool) void {
57-
self.use_color = enabled;
57+
self.useColor = enabled;
5858
}
5959

6060
pub fn info(self: *Logger, comptime fmt: []const u8, args: anytype) !void {
@@ -81,26 +81,26 @@ pub const Logger = struct {
8181
const ts = try formatTimestamp(a);
8282

8383
const tag = levelTag(level);
84-
const tag_color = levelColor(level);
84+
const tagColor = levelColor(level);
8585

8686
const msg = try std.fmt.allocPrint(a, fmt, args);
8787

8888
const errf = std.fs.File.stderr();
8989

90-
const line = try if (self.use_color)
90+
const line = try if (self.useColor)
9191
std.fmt.allocPrint(
9292
a,
9393
"{s}{s}{s} {s}[{s}]{s} {s}{s}{s} {s}\n",
94-
.{ Dim, ts, Reset, tag_color, tag, Reset, Cyan, self.name, Reset, msg },
94+
.{ Dim, ts, Reset, tagColor, tag, Reset, Cyan, self.name, Reset, msg },
9595
)
9696
else
9797
std.fmt.allocPrint(a, "{s} [{s}] {s} {s}\n", .{ ts, tag, self.name, msg });
9898

9999
try errf.writeAll(line);
100100

101101
if (self.file) |_| {
102-
const plain_line = try std.fmt.allocPrint(a, "{s} [{s}] {s} {s}\n", .{ ts, tag, self.name, msg });
103-
self.writeRaw(plain_line);
102+
const plainLine = try std.fmt.allocPrint(a, "{s} [{s}] {s} {s}\n", .{ ts, tag, self.name, msg });
103+
self.writeRaw(plainLine);
104104
}
105105
}
106106

0 commit comments

Comments
 (0)