mirror of https://github.com/Hilbis/Hilbish
docs: add docs for os interface
parent
c45c6a61bc
commit
525635787a
8
api.go
8
api.go
|
@ -19,7 +19,6 @@ import (
|
||||||
rt "github.com/arnodel/golua/runtime"
|
rt "github.com/arnodel/golua/runtime"
|
||||||
"github.com/arnodel/golua/lib/packagelib"
|
"github.com/arnodel/golua/lib/packagelib"
|
||||||
"github.com/maxlandon/readline"
|
"github.com/maxlandon/readline"
|
||||||
"github.com/blackfireio/osinfo"
|
|
||||||
"mvdan.cc/sh/v3/interp"
|
"mvdan.cc/sh/v3/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -119,12 +118,7 @@ func hilbishLoad(rtm *rt.Runtime) (rt.Value, func()) {
|
||||||
mod.Set(rt.StringValue("userDir"), rt.TableValue(hshuser))
|
mod.Set(rt.StringValue("userDir"), rt.TableValue(hshuser))
|
||||||
|
|
||||||
// hilbish.os table
|
// hilbish.os table
|
||||||
hshos := rt.NewTable()
|
hshos := hshosLoader(rtm)
|
||||||
info, _ := osinfo.GetOSInfo()
|
|
||||||
|
|
||||||
util.SetField(rtm, hshos, "family", rt.StringValue(info.Family), "Family name of the current OS")
|
|
||||||
util.SetField(rtm, hshos, "name", rt.StringValue(info.Name), "Pretty name of the current OS")
|
|
||||||
util.SetField(rtm, hshos, "version", rt.StringValue(info.Version), "Version of the current OS")
|
|
||||||
util.Document(hshos, "OS info interface")
|
util.Document(hshos, "OS info interface")
|
||||||
mod.Set(rt.StringValue("os"), rt.TableValue(hshos))
|
mod.Set(rt.StringValue("os"), rt.TableValue(hshos))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hilbish/util"
|
||||||
|
|
||||||
|
rt "github.com/arnodel/golua/runtime"
|
||||||
|
"github.com/blackfireio/osinfo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// #interface os
|
||||||
|
// OS Info
|
||||||
|
// The `os` interface provides simple text information properties about
|
||||||
|
// the current OS on the systen. This mainly includes the name and
|
||||||
|
// version.
|
||||||
|
// #property family Family name of the current OS
|
||||||
|
// #property name Pretty name of the current OS
|
||||||
|
// #property version Version of the current OS
|
||||||
|
func hshosLoader(rtm *rt.Runtime) *rt.Table {
|
||||||
|
info, _ := osinfo.GetOSInfo()
|
||||||
|
mod := rt.NewTable()
|
||||||
|
|
||||||
|
util.SetField(rtm, mod, "family", rt.StringValue(info.Family), "Family name of the current OS")
|
||||||
|
util.SetField(rtm, mod, "name", rt.StringValue(info.Name), "Pretty name of the current OS")
|
||||||
|
util.SetField(rtm, mod, "version", rt.StringValue(info.Version), "Version of the current OS")
|
||||||
|
|
||||||
|
return mod
|
||||||
|
}
|
Loading…
Reference in New Issue