From 90e7ac5b453272e59a4f7403549990d7aae6cf55 Mon Sep 17 00:00:00 2001 From: samposa_1337 Date: Sun, 8 Nov 2026 13:49:40 +0300 Subject: full rewrite in 17.1 zig --- src/main.zig | 63 ++++++++++++++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 36 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 6080a47..fb35199 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,40 +1,31 @@ const std = @import("std"); -const stat = @import("stat.zig"); +const Io = std.Io; +const st = @import("stat.zig"); const artd = @import("art.zig"); +pub fn main(init: std.process.Init) !void { + const allocator = init.arena.allocator(); + const ke = try st.getkernel(init.io ,allocator); + const cpu = try st.getcpu(init.io ,allocator); + const osg = try st.getos(init.io ,allocator); + const ram = try st.getram(init.io ,allocator); + const ramq = try st.gettotal(init.io ,allocator); + const uptime = try st.uptime(init.io ,allocator); + const user = try st.getuser(init.environ_map ,allocator); + const shell = try st.getshell(init.environ_map ,allocator); - - -pub fn main() !void { - const stdout = std.io.getStdOut().writer(); - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - defer _ = gpa.deinit(); - const allocator = gpa.allocator(); - const cpuq = try stat.getcput(allocator); - const shell = try stat.shellenv(allocator); - defer allocator.free(shell); - defer allocator.free(cpuq); - const kernel = try stat.getkernel(allocator); - defer allocator.free(kernel); - const osd = try stat.getos(allocator); - defer allocator.free(osd); - const ram = try stat.ramInfo(allocator); - defer allocator.free(ram); - const hst = try stat.gethst(allocator); - defer allocator.free(hst); - const ge = try stat.GetRam(allocator); - defer allocator.free(ge); - const user = try stat.users(allocator); - defer allocator.free(user); - const trm = try stat.uptime(allocator); - defer allocator.free(trm); - const art = artd.logo; - try stdout.print(" Ezfetch\n", .{}); - try stdout.print("{s} -----------------\n", .{art[0]}); - try stdout.print("{s} Os: {s}\n", .{ art[1], osd }); - try stdout.print("{s} User@hostname: {s}@{s}\n", .{ art[2], user, hst }); - try stdout.print("{s} Kernel: {s}\n", .{ art[3], kernel }); - try stdout.print("{s} Cpu: {s}\n", .{ art[4], cpuq }); - try stdout.print("{s} Ram: {s} / {s}\n", .{ art[5], ge, ram }); - try stdout.print(" larptime: {s}\n", .{trm}); - try stdout.print(" shell: {s}\n", .{shell}); + const hostname = try st.gethostname(init.io ,allocator); + var bufs: [1024]u8 = undefined; + var stdw = Io.File.stdout().writer(init.io, &bufs); + const stdout = &stdw.interface; + const art = artd.logo; + try stdout.print(" Ezfetch\n", .{}); + try stdout.print("{s} -----------------\n", .{art[0]}); + try stdout.print("{s} Os: {s}\n", .{art[1],osg}); + try stdout.print("{s} Username@hostname: {s}@{s}\n", .{art[2],user,hostname}); + try stdout.print("{s} Kernel: {s}\n", .{art[3],ke}); + try stdout.print("{s} Cpu: {s}\n", .{art[4],cpu}); + try stdout.print("{s} Ram: {s} / {s} \n", .{art[5],ramq,ram}); + try stdout.print(" larptime: {s}\n", .{uptime}); + try stdout.print(" shell: {s}\n", .{shell}); + try stdout.flush(); } -- cgit v1.3