فهرست منبع

add more builtin modules

ruki 6 ماه پیش
والد
کامیت
cd6741195c

+ 44 - 0
docs/api/scripts/builtin-modules/linuxos.md

@@ -0,0 +1,44 @@
+
+# linuxos
+
+The linux system operation module is a built-in module, no need to use [import](/api/scripts/builtin-modules/import) to import,
+and its interface can be called directly in the script scope.
+
+## linuxos.name
+
+- Get linux system name
+
+We can also quickly get the view through the following command
+
+```bash
+xmake l linuxos.name
+```
+
+Some names currently supported are:
+
+- ubuntu
+- debian
+- archlinux
+- manjaro
+- linuxmint
+- centos
+- fedora
+- opensuse
+
+## linuxos.version
+
+- Get linux system version
+
+The version returned is the semver semantic version object
+
+```lua
+if linux.version():ge("10.0") then
+    -- ...
+end
+```
+
+## linuxos.kernelver
+
+- Get linux system kernel version
+
+What is returned is also a semantic version object, you can also execute `xmake l linuxos.kernelver` to quickly view.

+ 15 - 0
docs/api/scripts/builtin-modules/macos.md

@@ -0,0 +1,15 @@
+# macos
+
+The macOS system operation module is a built-in module, no need to use [import](/api/scripts/builtin-modules/import) to import, you can directly call its interface in the script scope.
+
+## macos.version
+
+- Get macOS system version
+
+The version returned is the semver semantic version object
+
+```lua
+if macos.version():ge("10.0") then
+    - ...
+end
+```

+ 75 - 0
docs/api/scripts/builtin-modules/winos.md

@@ -0,0 +1,75 @@
+# winos
+
+The windows system operation module is a built-in module, no need to use [import](/api/scripts/builtin-modules/import) to import,
+you can directly call its interface in the script scope.
+
+## winos.version
+
+- Get windows system version
+
+The version returned is the semver semantic version object
+
+```lua
+if winos.version():ge("win7") then
+    - ...
+end
+
+if winos.version():ge("6.1") then
+    - ...
+end
+```
+
+In addition, it can also support the direct judgment of the windows version name. The mapping rules are as follows:
+
+```
+nt4 = "4.0"
+win2k = "5.0"
+winxp = "5.1"
+ws03 = "5.2"
+win6 = "6.0"
+vista = "6.0"
+ws08 = "6.0"
+longhorn = "6.0"
+win7 = "6.1"
+win8 = "6.2"
+winblue = "6.3"
+win81 = "6.3"
+win10 = "10.0"
+```
+
+## winos.registry_keys
+
+- Get the list of registry builds
+
+Support through pattern matching, traverse to obtain the registry key path list, `*` is single-level path matching, `**` is recursive path matching.
+
+```lua
+local keypaths = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\*\\Windows NT\\*\\CurrentVersion\\AeDebug")
+for _, keypath in ipairs(keypaths) do
+    print(winos.registry_query(keypath .. ";Debugger"))
+end
+```
+
+## winos.registry_values
+
+- Get a list of registry value names
+
+Support to obtain the value name list of the specified key path through pattern matching, and the string after the `;` is the specified key name pattern matching string.
+
+```lua
+local valuepaths = winos.registry_values("HKEY_LOCAL_MACHINE\\SOFTWARE\\xx\\AeDebug;Debug*")
+for _, valuepath in ipairs(valuepaths) do
+    print(winos.registry_query(valuepath))
+end
+```
+
+## winos.registry_query
+
+- Get the registry value
+
+Get the value under the specified registry path, if the value name is not specified, then get the default value of the key path
+
+```lua
+local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug")
+local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger")
+```

+ 3 - 0
docs/config.ts

@@ -144,6 +144,9 @@ function scriptsApiSidebar(): DefaultTheme.SidebarItem[] {
         { text: 'vformat', link: 'builtin-modules/vformat' },
         { text: 'raise', link: 'builtin-pmodules/raise' },
         { text: 'os', link: 'builtin-modules/os' },
+        { text: 'winos', link: 'builtin-modules/winos' },
+        { text: 'macos', link: 'builtin-modules/macos' },
+        { text: 'linuxos', link: 'builtin-modules/linuxos' },
       ]
     },
     {

+ 43 - 0
docs/zh/api/scripts/builtin-modules/linuxos.md

@@ -0,0 +1,43 @@
+
+# linuxos
+
+Linux 系统操作模块,属于内置模块,无需使用[import](/zh/api/scripts/builtin-modules/import)导入,可直接脚本域调用其接口。
+
+## linuxos.name
+
+- 获取 linux 系统发行版名称
+
+我们也可以通过下面的命令,快速获取查看
+
+```bash
+xmake l linuxos.name
+```
+
+目前支持的一些名称有:
+
+- ubuntu
+- debian
+- archlinux
+- manjaro
+- linuxmint
+- centos
+- fedora
+- opensuse
+
+## linuxos.version
+
+- 获取 linux 系统版本
+
+返回的版本是 semver 语义版本对象
+
+```lua
+if linux.version():ge("10.0") then
+    -- ...
+end
+```
+
+## linuxos.kernelver
+
+- 获取 linux 系统内核版本
+
+返回的也是语义版本对象,也可以执行 `xmake l linuxos.kernelver` 快速查看

+ 16 - 0
docs/zh/api/scripts/builtin-modules/macos.md

@@ -0,0 +1,16 @@
+
+# macos
+
+macOS 系统操作模块,属于内置模块,无需使用[import](/zh/api/scripts/builtin-modules/import)导入,可直接脚本域调用其接口。
+
+## macos.version
+
+- 获取 macOS 系统版本
+
+返回的版本是 semver 语义版本对象
+
+```lua
+if macos.version():ge("10.0") then
+    -- ...
+end
+```

+ 76 - 0
docs/zh/api/scripts/builtin-modules/winos.md

@@ -0,0 +1,76 @@
+
+# winos
+
+Windows 系统操作模块,属于内置模块,无需使用[import](/zh/api/scripts/builtin-modules/import)导入,可直接脚本域调用其接口。
+
+## winos.version
+
+- 获取 windows 系统版本
+
+返回的版本是 semver 语义版本对象
+
+```lua
+if winos.version():ge("win7") then
+    -- ...
+end
+
+if winos.version():ge("6.1") then
+    -- ...
+end
+```
+
+并且,还可以支持对 windows 版本名的直接判断,映射规则如下:
+
+```
+
+nt4      = "4.0"
+win2k    = "5.0"
+winxp    = "5.1"
+ws03     = "5.2"
+win6     = "6.0"
+vista    = "6.0"
+ws08     = "6.0"
+longhorn = "6.0"
+win7     = "6.1"
+win8     = "6.2"
+winblue  = "6.3"
+win81    = "6.3"
+win10    = "10.0"
+```
+
+## winos.registry_keys
+
+- 获取注册表建列表
+
+支持通过模式匹配的方式,遍历获取注册表键路径列表,`*` 为单级路径匹配,`**` 为递归路径匹配。
+
+```lua
+local keypaths = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\*\\Windows NT\\*\\CurrentVersion\\AeDebug")
+for _, keypath in ipairs(keypaths) do
+    print(winos.registry_query(keypath .. ";Debugger"))
+end
+```
+
+## winos.registry_values
+
+- 获取注册表值名列表
+
+支持通过模式匹配的方式,获取指定键路径的值名列表,`;` 之后的就是指定的键名模式匹配字符串。
+
+```lua
+local valuepaths = winos.registry_values("HKEY_LOCAL_MACHINE\\SOFTWARE\\xx\\AeDebug;Debug*")
+for _, valuepath in ipairs(valuepaths) do
+    print(winos.registry_query(valuepath))
+end
+```
+
+## winos.registry_query
+
+- 获取注册表建值
+
+获取指定注册表建路径下的值,如果没有指定值名,那么获取键路径默认值
+
+```lua
+local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug")
+local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger")
+```

+ 3 - 0
docs/zh/config.ts

@@ -225,6 +225,9 @@ function scriptsApiSidebar(): DefaultTheme.SidebarItem[] {
         { text: 'vformat', link: 'builtin-modules/vformat' },
         { text: 'raise', link: 'builtin-pmodules/raise' },
         { text: 'os', link: 'builtin-modules/os' },
+        { text: 'winos', link: 'builtin-modules/winos' },
+        { text: 'macos', link: 'builtin-modules/macos' },
+        { text: 'linuxos', link: 'builtin-modules/linuxos' },
       ]
     },
     {