diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..6451016 --- /dev/null +++ b/src/main.zig @@ -0,0 +1,30 @@ +const std = @import("std"); +const eq = std.mem.eql; + +const ls = @import("ls.zig"); +const cat = @import("cat.zig"); + +const lib = @import("lib.zig"); + +fn help() void { + const help_string = + \\ + \\ toying with a single tool: zig build-exe ls.zig + \\ (currently ± working tools: cat, ls) + \\ + \\ global compilation: zig build-exe main.zig + \\ -> produces "main" that includes all tools + \\ you can invoke each tool by creating a symbolic link to "main" + \\ ex: ln -s main ls <- now you have "ls" working as your well-known "ls" :) + ; + lib.print("{s}\n", .{help_string}); +} + +pub fn main() !void { + const args = try std.process.argsAlloc(std.heap.page_allocator); + const bname = std.fs.path.basename(args[0]); + + if (eq(u8, bname, "ls")) { try ls.main(); } + else if (eq(u8, bname, "cat")) { try cat.main(); } + else { help(); } +}