ruki hace 6 meses
padre
commit
b1443d9f93

+ 15 - 0
docs/api/scripts/extension-modules/net/http.md

@@ -0,0 +1,15 @@
+# net.http
+
+This module provides various operational support for http. The currently available interfaces are as follows:
+
+## http.download
+
+- Download http file
+
+This interface is relatively simple, is simply download files.
+
+```lua
+import("net.http")
+
+http.download("https://xmake.io", "/tmp/index.html")
+```

+ 64 - 0
docs/api/scripts/extension-modules/privilege/sudo.md

@@ -0,0 +1,64 @@
+
+# privilege.sudo
+
+This interface is used to run commands via `sudo` and provides platform consistency handling, which can be used for scripts that require root privileges to run.
+
+::: tip NOTE
+In order to ensure security, unless you must use it, try not to use this interface in other cases.
+:::
+
+## sudo.has
+
+- Determine if sudo supports
+
+At present, sudo is supported only under `macosx/linux`. The administrator privilege running on Windows is not supported yet. Therefore, it is recommended to use the interface to judge the support situation before use.
+
+```lua
+import("privilege.sudo")
+
+if sudo.has() then
+    sudo.run("rm /system/file")
+end
+```
+
+## sudo.run
+
+- Quietly running native shell commands
+
+For specific usage, please refer to: [os.run](/api/scripts/builtin-modules/os#os-run).
+
+```lua
+import("privilege.sudo")
+
+sudo.run("rm /system/file")
+```
+
+## sudo.runv
+
+- Quietly running native shell commands with parameter list
+
+For specific usage, please refer to: [os.runv](/api/scripts/builtin-modules/os#os-runv).
+
+## sudo.exec
+
+- Echo running native shell commands
+
+For specific usage, please refer to: [os.exec](/api/scripts/builtin-modules/os#os-exec).
+
+## sudo.execv
+
+- Echo running native shell commands with parameter list
+
+For specific usage, please refer to: [os.execv](/api/scripts/builtin-modules/os#os-execv).
+
+## sudo.iorun
+
+- Quietly running native shell commands and getting output
+
+For specific usage, please refer to: [os.iorun](/api/scripts/builtin-modules/os#os-iorun).
+
+## sudo.iorunv
+
+- Run the native shell command quietly and get the output with a list of parameters
+
+For specific usage, please refer to: [os.iorunv](/api/scripts/builtin-modules/os#os-iorunv).

+ 21 - 0
docs/sidebar.ts

@@ -31,6 +31,8 @@ export function extensionModulesApiSidebarItems(): DefaultTheme.SidebarItem[] {
   return [
     coreModulesApiSidebar(),
     libModulesApiSidebar(),
+    netModulesApiSidebar(),
+    privilegeModulesApiSidebar(),
   ]
 }
 
@@ -103,3 +105,22 @@ function libModulesApiSidebar(): DefaultTheme.SidebarItem {
   }
 }
 
+function netModulesApiSidebar(): DefaultTheme.SidebarItem {
+  return {
+    text: 'net',
+    collapsed: true,
+    items: [
+      { text: 'http', link: 'extension-modules/net/http' },
+    ]
+  }
+}
+
+function privilegeModulesApiSidebar(): DefaultTheme.SidebarItem {
+  return {
+    text: 'privilege',
+    collapsed: true,
+    items: [
+      { text: 'sudo', link: 'extension-modules/privilege/sudo' },
+    ]
+  }
+}

+ 15 - 0
docs/zh/api/scripts/extension-modules/net/nttp.md

@@ -0,0 +1,15 @@
+# net.http
+
+此模块提供http的各种操作支持,目前提供的接口如下:
+
+## http.download
+
+- 下载http文件
+
+这个接口比较简单,就是单纯的下载文件。
+
+```lua
+import("net.http")
+
+http.download("https://xmake.io", "/tmp/index.html")
+```

+ 64 - 0
docs/zh/api/scripts/extension-modules/privilege/sudo.md

@@ -0,0 +1,64 @@
+
+# privilege.sudo
+
+此接口用于通过`sudo`来运行命令,并且提供了平台一致性处理,对于一些需要root权限运行的脚本,可以使用此接口。
+
+::: tip 注意
+为了保证安全性,除非必须使用的场合,其他情况下尽量不要使用此接口。
+:::
+
+## sudo.has
+
+-  判断sudo是否支持
+
+目前仅在`macosx/linux`下支持sudo,windows上的管理员权限运行暂时还不支持,因此建议使用前可以通过此接口判断支持情况后,针对性处理。
+
+```lua
+import("privilege.sudo")
+
+if sudo.has() then
+    sudo.run("rm /system/file")
+end
+```
+
+## sudo.run
+
+- 安静运行原生shell命令
+
+具体用法可参考:[os.run](/zh/api/scripts/builtin-modules/os#os-run)。
+
+```lua
+import("privilege.sudo")
+
+sudo.run("rm /system/file")
+```
+
+## sudo.runv
+
+- 安静运行原生shell命令,带参数列表
+
+具体用法可参考:[os.runv](/zh/api/scripts/builtin-modules/os#os-runv)。
+
+## sudo.exec
+
+- 回显运行原生shell命令
+
+具体用法可参考:[os.exec](/zh/api/scripts/builtin-modules/os#os-exec)。
+
+## sudo.execv
+
+- 回显运行原生shell命令,带参数列表
+
+具体用法可参考:[os.execv](/zh/api/scripts/builtin-modules/os#os-execv)。
+
+## sudo.iorun
+
+- 安静运行原生shell命令并获取输出内容
+
+具体用法可参考:[os.iorun](/zh/api/scripts/builtin-modules/os#os-iorun)。
+
+## sudo.iorunv
+
+- 安静运行原生shell命令并获取输出内容,带参数列表
+
+具体用法可参考:[os.iorunv](/zh/api/scripts/builtin-modules/os#os-iorunv)。