12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- use std
- use "dispatch"
- use "cat"
- const uname = {params
-
- std.put("uname called\n")
-
- var info
- std.getsysinfo(&info)
-
- for option : params
-
- option = params[0]
-
- var hostname
- var readline = std.slurp("/proc/sys/kernel/hostname")
- match readline
- | `std.Ok dat: hostname = std.strstrip(dat)
- | `std.Err msg: std.put("Failed to read file: {}\n", msg)
- ;;
-
- match option
- | "-a" : std.put("{} {} {} {} {}\n",info.system,hostname,info.release,info.version,info.arch)
- | "-m" : std.put("{}\n",info.arch)
- | "-v" : std.put("{}\n",info.version)
- | "-r" : std.put("{}\n",info.release)
- | "-s" : std.put("{}\n",info.system)
- | "-n" : std.put("{}\n",hostname)
- | _ : std.put("{}\n","no info")
- ;;
- std.exit(1)
- ;;
-
- std.put("{}\n",info.system)
- }
- const __init__ = {
- dispatch.register("uname",uname)
- }
|