Skip to content

Commit f0cdcbd

Browse files
refactor: move help documentation to cli module
1 parent 7364159 commit f0cdcbd

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/cli.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ fn watchFileChanges(self: *CLI, polling_rate_ms: u64) !void {
138138

139139
STD.Thread.sleep(@intCast(polling_rate_ms * 1_000_000));
140140
}
141+
pub fn help_documentation() void {
142+
STD.debug.print("{s}\n", .{ASCII_ART});
143+
STD.debug.print("cpplings [OPTION]\n\n", .{});
144+
STD.debug.print("Options:\n", .{});
145+
STD.debug.print("-h | --help | help -> output this help documentation\n", .{});
146+
STD.debug.print("-p | --patch -> generate patch files\n", .{});
147+
STD.debug.print("-s | --solutions -> run and test cpplings against solutions dir\n", .{});
141148
}
142149

143150
fn compileCurrentExercise(self: *CLI) !void {

src/main.zig

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@ const STD = @import("std");
33
const CLI = @import("cli.zig");
44
const PATCH_SYSTEM = @import("patch.zig");
55

6-
pub fn help_documentation() void {
7-
STD.debug.print("{s}\n", .{CLI.ASCII_ART});
8-
STD.debug.print("cpplings [OPTION]\n\n", .{});
9-
STD.debug.print("Options:\n", .{});
10-
STD.debug.print("-h | --help | help -> output this help documentation\n", .{});
11-
STD.debug.print("-p | --patch -> generate patch files\n", .{});
12-
STD.debug.print("-s | --solutions -> run and test cpplings against solutions dir\n", .{});
13-
}
14-
156
pub fn main() !void {
167
var mem_arena = STD.heap.ArenaAllocator.init(STD.heap.page_allocator);
178
defer mem_arena.deinit();
@@ -20,7 +11,7 @@ pub fn main() !void {
2011

2112
if (STD.os.argv.len > 2) {
2213
STD.debug.print("Too many arguments\n", .{});
23-
help_documentation();
14+
CLI.help_documentation();
2415
}
2516

2617
if (STD.os.argv.len == 1) {
@@ -36,8 +27,8 @@ pub fn main() !void {
3627
const PATCH_SYSTEM_INSTANCE = try PATCH_SYSTEM.PatchSystem.init(ALLOCATOR, .{});
3728
defer PATCH_SYSTEM_INSTANCE.deinit(ALLOCATOR);
3829
} 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")) {
39-
help_documentation();
30+
CLI.help_documentation();
4031
} else {
41-
help_documentation();
32+
CLI.help_documentation();
4233
}
4334
}

0 commit comments

Comments
 (0)