uname.myr 827 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use std
  2. use "dispatch"
  3. use "cat"
  4. const uname = {params
  5. std.put("uname called\n")
  6. var info
  7. std.getsysinfo(&info)
  8. for option : params
  9. option = params[0]
  10. var hostname
  11. var readline = std.slurp("/proc/sys/kernel/hostname")
  12. match readline
  13. | `std.Ok dat: hostname = std.strstrip(dat)
  14. | `std.Err msg: std.put("Failed to read file: {}\n", msg)
  15. ;;
  16. match option
  17. | "-a" : std.put("{} {} {} {} {}\n",info.system,hostname,info.release,info.version,info.arch)
  18. | "-m" : std.put("{}\n",info.arch)
  19. | "-v" : std.put("{}\n",info.version)
  20. | "-r" : std.put("{}\n",info.release)
  21. | "-s" : std.put("{}\n",info.system)
  22. | "-n" : std.put("{}\n",hostname)
  23. | _ : std.put("{}\n","no info")
  24. ;;
  25. std.exit(1)
  26. ;;
  27. std.put("{}\n",info.system)
  28. }
  29. const __init__ = {
  30. dispatch.register("uname",uname)
  31. }