diff options
author | makefunstuff <[email protected]> | 2024-06-30 18:10:56 +0200 |
---|---|---|
committer | makefunstuff <[email protected]> | 2024-06-30 18:10:56 +0200 |
commit | da3127207870db7e560540f8d318ffe55cdf73a6 (patch) | |
tree | f9e45fc7c893bb5ff1864ab006f3444e6e36c9cb /src | |
download | tinkerbunk-da3127207870db7e560540f8d318ffe55cdf73a6.tar.gz |
zigging some meh
Diffstat (limited to 'src')
-rw-r--r-- | src/ls.zig | 12 | ||||
-rw-r--r-- | src/main.zig | 27 | ||||
-rw-r--r-- | src/socket-server.zig | 3 |
3 files changed, 42 insertions, 0 deletions
diff --git a/src/ls.zig b/src/ls.zig new file mode 100644 index 0000000..64e27cf --- /dev/null +++ b/src/ls.zig @@ -0,0 +1,12 @@ +const std = @import("std"); + +pub fn ls() !void { + const dir = try std.fs.cwd().openDir(".", .{ .iterate = true }); + + var iterator = dir.iterate(); + + while (try iterator.next()) |entry| { + const name = entry.name; + std.debug.print("{s}\n", .{name}); + } +} diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..b46023e --- /dev/null +++ b/src/main.zig @@ -0,0 +1,27 @@ +const std = @import("std"); +const ls = @import("ls.zig"); + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + defer _ = gpa.deinit(); + + const args = try std.process.argsAlloc(allocator); + defer std.process.argsFree(allocator, args); + + if (args.len == 2 and std.mem.eql(u8, args[1], "help")) { + print_help(); + return; + } + if (args.len == 2 and std.mem.eql(u8, args[1], "ls")) { + try ls.ls(); + return; + } + + std.debug.print("Unknown command. Use 'help' for usage information.\n", .{}); + print_help(); +} + +fn print_help() void { + std.debug.print("[usage] tinkerbunk ls\n", .{}); +} diff --git a/src/socket-server.zig b/src/socket-server.zig new file mode 100644 index 0000000..01c5790 --- /dev/null +++ b/src/socket-server.zig @@ -0,0 +1,3 @@ +const std = @import("std"); + +pub fn start_server() !void {} |