aboutsummaryrefslogtreecommitdiff
path: root/binaries
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-13 13:54:50 +0530
committerBobby <[email protected]>2026-02-13 13:54:50 +0530
commitda6d54db5d741f2db0810cf7afb0b2d5bf0f7113 (patch)
tree583043d06894bde66cdb501c745477ef4c9c5859 /binaries
parentc9078cc59cd5099fdc62e0b38799a2f8b67c3766 (diff)
downloadakiba-da6d54db5d741f2db0810cf7afb0b2d5bf0f7113.tar.xz
akiba-da6d54db5d741f2db0810cf7afb0b2d5bf0f7113.zip
refactor: Improve stack viewing and argument handling with enhanced error reporting and alignment
Diffstat (limited to 'binaries')
-rw-r--r--binaries/mi/mi.zig38
1 files changed, 25 insertions, 13 deletions
diff --git a/binaries/mi/mi.zig b/binaries/mi/mi.zig
index c614ed3..0f5e400 100644
--- a/binaries/mi/mi.zig
+++ b/binaries/mi/mi.zig
@@ -39,7 +39,20 @@ export fn main(pc: u32, pv: [*]const [*:0]const u8) u8 {
fn display_stack(path: []const u8) !void {
var entries: [128]akiba.io.StackEntry = undefined;
- const count = akiba.io.viewstack(path, &entries) catch 0;
+ const count = akiba.io.viewstack(path, &entries) catch {
+ // Path doesn't exist or isn't a directory
+ _ = akiba.io.mark(akiba.io.stream, "mi: cannot access '", Color.red) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, path, Color.white) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, "': No such stack.\n", Color.red) catch 0;
+ return;
+ };
+
+ // Check for empty directory (valid directory with 0 entries)
+ if (count == 0) {
+ _ = akiba.io.mark(akiba.io.stream, path, Color.cyan) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, " is empty.\n", Color.gray) catch 0;
+ return;
+ }
// Calculate max widths for each column
var max_access_len: usize = 6;
@@ -64,7 +77,7 @@ fn display_stack(path: []const u8) !void {
}
// Print header
- _ = akiba.io.mark(akiba.io.stream, "\nAccess", Color.white) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, "Access", Color.white) catch 0;
print_padding(max_access_len - 6 + 2);
_ = akiba.io.mark(akiba.io.stream, "Size", Color.white) catch 0;
print_padding(max_size_len - 4 + 2);
@@ -111,17 +124,16 @@ fn display_stack(path: []const u8) !void {
_ = akiba.io.mark(akiba.io.stream, "\n", Color.white) catch 0;
}
- if (count > 0) {
- _ = akiba.io.mark(akiba.io.stream, "\n", Color.white) catch 0;
- var buf: [16]u8 = undefined;
- _ = akiba.io.mark(akiba.io.stream, int_to_str(stack_count, &buf), Color.gray) catch 0;
- _ = akiba.io.mark(akiba.io.stream, " stacks ", Color.gray) catch 0;
- _ = akiba.io.mark(akiba.io.stream, int_to_str(unit_count, &buf), Color.gray) catch 0;
- _ = akiba.io.mark(akiba.io.stream, " units ", Color.gray) catch 0;
- var size_buf: [32]u8 = undefined;
- _ = akiba.io.mark(akiba.io.stream, format_size(total_size, &size_buf), Color.gray) catch 0;
- _ = akiba.io.mark(akiba.io.stream, "\n\n", Color.white) catch 0;
- }
+ _ = akiba.io.mark(akiba.io.stream, "\n", Color.white) catch 0;
+ // Summary
+ var buf: [16]u8 = undefined;
+ _ = akiba.io.mark(akiba.io.stream, int_to_str(stack_count, &buf), Color.gray) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, " stacks ", Color.gray) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, int_to_str(unit_count, &buf), Color.gray) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, " units ", Color.gray) catch 0;
+ var size_buf: [32]u8 = undefined;
+ _ = akiba.io.mark(akiba.io.stream, format_size(total_size, &size_buf), Color.gray) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, "\n", Color.white) catch 0;
}
fn get_permissions(perm_type: u8) []const u8 {