Reference · Command Line Interface (v0.1.0)
命令行接口参考 (CLI Reference)
gpux-cli 是 GPUX 的官方命令行工具链,提供从 8 平台脚手架生成、热重载开发、交叉编译打包、图标生成、ACL 权限同步到系统插件管理的全生命周期支持。
安装与 9 种调用方式
你可以通过原生 Shell 脚本、Cargo 或前端包管理器直接调用 GPUX CLI:
cargo install gpux-cli
gpux --help
curl -fsSL https://gpux.waya.ink/install.sh | bash
gpux --help
irm https://gpux.waya.ink/install.ps1 | iex
gpux --help
curl -fsSL https://gpux.waya.ink/install.fish | source
gpux --help
npm create gpux@latest my-app
pnpm create gpux my-app
yarn create gpux my-app
bun create gpux my-app
deno run -A npm:create-gpux@latest my-app
命令总览表 (Command Matrix)
| 命令 | 别名 | 核心用途 |
|---|---|---|
gpux init | create | 初始化 8 平台 GPUX 工程目录(Desktop + iOS + Android + HarmonyOS + Web + MiniProgram) |
gpux dev | — | 启动指定目标平台的开发服务器与原生 GPU 窗口热重载会话 |
gpux build | — | 交叉编译并打包生产分发产物(.dmg / .msi / .AppImage / .ipa / .apk / .hap / .wasm) |
gpux doctor | info | 诊断本机操作系统、GPU 后端、Rust Target Triples 与移动端 SDK 环境 |
gpux plugin | — | 添加、移除或列出官方与社区原生系统插件(add / remove / list) |
gpux permission | — | 检视与授权 gpux.json 中的细粒度 ACL 安全权限(list / add) |
gpux icon | — | 从单张高清 SVG/PNG 源文件生成全平台应用图标矩阵 |
gpux migrate | — | 自动迁移旧版本 gpux.json Schema 并对齐 Workspace 依赖 |
init / create
在当前目录或指定父目录下创建一套开箱即用的 8 端 GPUX 工程,包含 gpux.json、共享视图库 src/lib.rs、桌面端入口 src/main.rs 以及 platforms/{ios,android,ohos,web,miniprogram} 宿主目录。
| 参数 / 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
<NAME> | String | 必填 | 工程名称与包标识符后缀(如 my-studio) |
-p, --path <PATH> | PathBuf | . | 指定生成工程的父级目录路径 |
dev
以开发模式启动应用。桌面端直接拉起原生 Metal / Vulkan / DirectX 12 窗口;Web 与小程序目标自动编译 wasm32-unknown-unknown 并挂载 WebGPU/WebGL2 画布;移动端自动调用对应模拟器或真机 Runner。
| 选项 | 可选值 | 默认值 | 说明 |
|---|---|---|---|
-t, --target <TARGET> |
desktop | macos | linux | windows | ios | android | harmonyos (ohos) | web | miniprogram (weapp) |
desktop |
指定运行的目标平台与关联的 Rust Target Triple |
build
执行 LTO 优化编译并调用对应平台的原生打包器生成可分发安装包。
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
-t, --target <TARGET> | TargetPlatform | desktop | 目标构建平台(决定调用 cargo build、cargo ndk、ohrs build 或 wasm-pack) |
--release | bool | true | 是否启用 Release 编译配置与符号剥离 |
doctor / info
输出当前宿主机平台、桌面 GPU 驱动就绪状态,并逐项检测 cargo-ndk(Android)、ohrs(HarmonyOS NEXT)、xcodegen(iOS)与 wasm-pack / wasm-bindgen(Web & MiniProgram)是否已安装。
plugin
| 子命令 | 示例 | 说明 |
|---|---|---|
plugin add <NAME> | gpux plugin add biometric | 注册官方系统插件并向 gpux.json 自动写入默认 ACL 权限声明 |
plugin remove <NAME> | gpux plugin remove biometric | 移除指定插件及其关联的权限配置 |
plugin list | gpux plugin list | 列出全部官方 8 端统一系统插件(clipboard、storage、notification、biometric、haptics、dialog、updater、tray) |
permission
管理 ServiceRegistry 与原生桥接方法的最小权限白名单:
gpux permission list— 列出当前工程已激活的 ACL 能力标识符。gpux permission add <CAPABILITY>— 授予新权限(例如gpux permission add clipboard:write-text)。
icon & migrate
gpux icon 默认读取 assets/icon.svg,一键生成 macOS .icns、Windows .ico、Linux 多分辨率 PNG、iOS Assets.xcassets、Android Adaptive Icons 与 HarmonyOS AppScope/resources 图标。
gpux migrate 自动检测并升级旧版工程配置至最新 GPUX Schema。