Skip to content

Commit a1ddbde

Browse files
refactor(cli): update patch system interface with args
1 parent 4a19fa1 commit a1ddbde

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/main.zig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@ pub fn help_documentation() void {
1515
pub fn main() !void {
1616
var mem_arena = STD.heap.ArenaAllocator.init(STD.heap.page_allocator);
1717
defer mem_arena.deinit();
18-
const MEM_ALLOCATOR = mem_arena.allocator();
18+
19+
const ALLOCATOR = mem_arena.allocator();
1920

2021
if (STD.os.argv.len > 2) {
2122
STD.debug.print("Too many arguments\n", .{});
2223
help_documentation();
2324
}
2425

2526
if (STD.os.argv.len == 1) {
26-
try CLI.run(MEM_ALLOCATOR, .{});
27+
try CLI.run(ALLOCATOR, .{});
2728
return;
2829
}
2930

3031
const PROGRAM_ARGUMENT = STD.mem.span(STD.os.argv[1]);
3132

3233
if (STD.mem.eql(u8, PROGRAM_ARGUMENT, "-s") or STD.mem.eql(u8, PROGRAM_ARGUMENT, "--solutions")) {
33-
try CLI.run(MEM_ALLOCATOR, .{ .exercises_dir_path = ".patches/solutions" });
34+
try CLI.run(ALLOCATOR, .{ .exercises_dir_path = ".patches/solutions" });
3435
} else if (STD.mem.eql(u8, PROGRAM_ARGUMENT, "-p") or STD.mem.eql(u8, PROGRAM_ARGUMENT, "--patch")) {
35-
try PATCH_SYSTEM.run(MEM_ALLOCATOR);
36+
const PATCH_SYSTEM_INSTANCE = try PATCH_SYSTEM.PatchSystem.init(ALLOCATOR, .{});
37+
defer PATCH_SYSTEM_INSTANCE.deinit(ALLOCATOR);
3638
} else if (STD.mem.eql(u8, PROGRAM_ARGUMENT, "-h") or STD.mem.eql(u8, PROGRAM_ARGUMENT, "--help") or STD.mem.eql(u8, PROGRAM_ARGUMENT, "help")) {
3739
help_documentation();
3840
} else {

src/patch.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const CLI = @import("cli.zig");
44
const UTIL = @import("util.zig");
55
const STYLES = @import("styles.zig");
66

7-
const PatchSystem = struct {
7+
pub const PatchSystem = struct {
88
const Self = @This();
99

1010
list_of_solution_file_paths: STD.ArrayList([]const u8),
@@ -137,7 +137,7 @@ const PatchSystem = struct {
137137
.data = diff_contents.items,
138138
});
139139

140-
STD.debug.print("\n{s}Generated patch -> {s}{s}{s}\n", .{
140+
STD.debug.print("\n{s}Generated patch -> {s}{s}{s}\n\n", .{
141141
STYLES.ASCII_STYLES.bold,
142142
STYLES.ASCII_STYLES.underline,
143143
patch_file_path,

0 commit comments

Comments
 (0)