From 829f455129189a866f41ffec124beedf3be937ce Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 21 Jul 2024 13:07:51 +0200 Subject: [PATCH] apps: Add arch --- apps/CMakeLists.txt | 1 + apps/arch.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 apps/arch.cpp diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 2c672152..fe237afd 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -53,3 +53,4 @@ luna_app(startui.cpp startui) luna_app(launch.cpp launch) luna_app(run.cpp run) luna_app(sha256sum.cpp sha256sum) +luna_app(arch.cpp arch) diff --git a/apps/arch.cpp b/apps/arch.cpp new file mode 100644 index 00000000..6ce1ad81 --- /dev/null +++ b/apps/arch.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +Result luna_main(int argc, char** argv) +{ + os::ArgumentParser parser; + parser.add_description("Print the current machine's architecture name."_sv); + parser.add_system_program_info("arch"_sv); + parser.parse(argc, argv); + + struct utsname info; + if (uname(&info) < 0) + { + perror("uname"); + return 1; + } + + os::println("%s", info.machine); + + return 0; +}