Skip to content

Commit fc36fc4

Browse files
refactor: use global vars as default parameters
1 parent 9672ebd commit fc36fc4

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/patch.zig

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

7+
pub const DEFAULT_ORIGINAL_DIR = "patches";
8+
pub const DEFAULT_MODIFIED_DIR: []const u8 = CLI.DEFAULT_EXERCISES_DIR;
9+
pub const DEFAULT_EXTENSION_FILTER = ".cpp";
10+
711
pub const PatchSystem = struct {
812
const Self = @This();
913

1014
list_of_solution_file_paths: STD.ArrayList([]const u8),
1115
list_of_exercise_file_paths: STD.ArrayList([]const u8),
1216

1317
pub fn init(allocator: STD.mem.Allocator, extra_options: struct {
14-
original_files_dir: []const u8 = ".patches",
15-
modified_dir: []const u8 = "exercises",
16-
extension_filter: []const u8 = ".cpp",
18+
original_files_dir: []const u8 = DEFAULT_ORIGINAL_DIR,
19+
modified_dir: []const u8 = DEFAULT_MODIFIED_DIR,
20+
extension_filter: []const u8 = DEFAULT_EXTENSION_FILTER,
1721
is_debug_enabled: bool = false,
1822
}) !*PatchSystem {
1923
STD.debug.print("{s}\n\n", .{CLI.ASCII_ART});
@@ -64,7 +68,7 @@ pub const PatchSystem = struct {
6468
self: *Self,
6569
allocator: STD.mem.Allocator,
6670
extra_options: struct {
67-
extension_filter: []const u8 = ".cpp",
71+
extension_filter: []const u8 = DEFAULT_EXTENSION_FILTER,
6872
is_debug_enabled: bool = false,
6973
},
7074
) !void {

0 commit comments

Comments
 (0)