45 lines
1.1 KiB
Zig
45 lines
1.1 KiB
Zig
const std = @import("std");
|
|
const mem = std.mem;
|
|
const stdout = std.io.getStdOut().writer();
|
|
const process = std.process;
|
|
|
|
const fs = std.fs;
|
|
|
|
const warn = std.debug.warn;
|
|
const print = std.debug.print;
|
|
|
|
const cli_arguments = @import("./cli_arguments.zig");
|
|
|
|
// TODO: error management.
|
|
|
|
pub fn ls() !void {
|
|
|
|
// Memory allocator for the cli arguments.
|
|
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
|
defer arena.deinit();
|
|
|
|
const allocator = &arena.allocator;
|
|
var args = try process.argsAlloc(allocator);
|
|
defer process.argsFree(allocator, args);
|
|
|
|
// Skipping the executable binary name.
|
|
var arg_idx: usize = 1;
|
|
|
|
const directory = cli_arguments.nextArg(args, &arg_idx) orelse {
|
|
warn("Expected first argument to be path to gui file\n", .{});
|
|
return error.InvalidArgs;
|
|
};
|
|
|
|
var current_working_directory: fs.Dir = fs.cwd();
|
|
var cwd: fs.Dir = try current_working_directory.openDir(directory, .{.iterate = true});
|
|
var dir_it = cwd.iterate();
|
|
|
|
while (try dir_it.next()) |entry| {
|
|
print("{}\n", .{entry.name});
|
|
}
|
|
}
|
|
|
|
pub fn main() !void {
|
|
try ls();
|
|
}
|