CLI
info
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri info
yarn tauri info
pnpm tauri info
bunx tauri info
cargo tauri info
Usage: cargo-tauri info [OPTIONS]
Options:
--interactive Interactive mode to apply automatic fixes
-v, --verbose... Enables verbose logging
-h, --help Print help
-V, --version Print version
它显示了关于环境、Rust、Node.js 及其版本以及一些相关配置的简洁信息列表。
当您需要快速了解您的应用程序时,此命令非常有用。在请求帮助时,与我们分享此报告会很有用。
init
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri init
yarn tauri init
pnpm tauri init
bunx tauri init
cargo tauri init
Usage: cargo-tauri init [OPTIONS]
Options:
--ci
Skip prompting for values
-v, --verbose...
Enables verbose logging
-f, --force
Force init to overwrite the src-tauri folder
-l, --log
Enables logging
-d, --directory <DIRECTORY>
Set target directory for init [default: /home/runner/work/tauri-docs/tauri-docs]
-t, --tauri-path <TAURI_PATH>
Path of the Tauri project to use (relative to the cwd)
-A, --app-name <APP_NAME>
Name of your Tauri application
-W, --window-title <WINDOW_TITLE>
Window title of your Tauri application
-D, --dist-dir <DIST_DIR>
Web assets location, relative to <project-dir>/src-tauri
-P, --dev-path <DEV_PATH>
Url of your dev server
--before-dev-command <BEFORE_DEV_COMMAND>
A shell command to run before `tauri dev` kicks in
--before-build-command <BEFORE_BUILD_COMMAND>
A shell command to run before `tauri build` kicks in
-h, --help
Print help
-V, --version
Print version
plugin init
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri plugin init
yarn tauri plugin init
pnpm tauri plugin init
bunx tauri plugin init
cargo tauri plugin init
Usage: cargo-tauri plugin init [OPTIONS] --name <PLUGIN_NAME>
Options:
-n, --name <PLUGIN_NAME> Name of your Tauri plugin
-v, --verbose... Enables verbose logging
--api Initializes a Tauri plugin with TypeScript API
-d, --directory <DIRECTORY> Set target directory for init [default: /home/runner/work/tauri-docs/tauri-docs]
-t, --tauri-path <TAURI_PATH> Path of the Tauri project to use (relative to the cwd)
-a, --author <AUTHOR> Author name
-h, --help Print help
-V, --version Print version
dev
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri dev
yarn tauri dev
pnpm tauri dev
bunx tauri dev
cargo tauri dev
Usage: cargo-tauri dev [OPTIONS] [ARGS]...
Arguments:
[ARGS]... Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments. Arguments after a second `--` are passed to the application e.g. `tauri dev -- [runnerArgs] -- [appArgs]`
Options:
-r, --runner <RUNNER> Binary to use to run the application
-v, --verbose... Enables verbose logging
-t, --target <TARGET> Target triple to build against
-f, --features [<FEATURES>...] List of cargo features to activate
-e, --exit-on-panic Exit on panic
-c, --config <CONFIG> JSON string or path to JSON file to merge with tauri.conf.json
--release Run the code in release mode
--no-watch Disable the file watcher
--no-dev-server Disable the dev server for static files
--port <PORT> Specify port for the dev server for static files. Defaults to 1430 Can also be set using `TAURI_DEV_SERVER_PORT` env var
-h, --help Print help
-V, --version Print version
此命令将在开发模式下打开 WebView。它使用您 `src-tauri/tauri.conf.json` 文件中的 `build.devPath` 属性。
如果您已将命令输入到 `build.beforeDevCommand` 属性中,则该命令将在 `dev` 命令之前执行。
如果您不使用 `build.beforeDevCommand`,请确保您的 `build.devPath` 正确无误,并且如果使用开发服务器,请确保在使用此命令之前启动它。
build
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri build
yarn tauri build
pnpm tauri build
bunx tauri build
cargo tauri build
Usage: cargo-tauri build [OPTIONS] [ARGS]...
Arguments:
[ARGS]...
Command line arguments passed to the runner. Use `--` to explicitly mark the start of the arguments
Options:
-r, --runner <RUNNER>
Binary to use to build the application, defaults to `cargo`
-v, --verbose...
Enables verbose logging
-d, --debug
Builds with the debug flag
-t, --target <TARGET>
Target triple to build against.
It must be one of the values outputted by `$rustc --print target-list` or `universal-apple-darwin` for an universal macOS application.
Note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed.
-f, --features [<FEATURES>...]
Space or comma separated list of features to activate
-b, --bundles [<BUNDLES>...]
Space or comma separated list of bundles to package.
Each bundle must be one of `deb`, `rpm`, `appimage`, `msi`, `app` or `dmg` on MacOS and `updater` on all platforms. If `none` is specified, the bundler will be skipped.
Note that the `updater` bundle is not automatically added so you must specify it if the updater is enabled.
-c, --config <CONFIG>
JSON string or path to JSON file to merge with tauri.conf.json
--ci
Skip prompting for values
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
此命令将捆绑您的应用程序,如果您使用了 `--debug` 标志,则以生产模式或调试模式捆绑。它使用您 `src-tauri/tauri.conf.json` 文件中的 `build.distDir` 属性。
如果您已将命令输入到 `build.beforeBuildCommand` 属性中,则该命令将在 `build` 命令之前执行。
icon
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri icon
yarn tauri icon
pnpm tauri icon
bunx tauri icon
cargo tauri icon
Usage: cargo-tauri icon [OPTIONS] [INPUT]
Arguments:
[INPUT] Path to the source icon (png, 1024x1024px with transparency) [default: ./app-icon.png]
Options:
-o, --output <OUTPUT> Output directory. Default: 'icons' directory next to the tauri.conf.json file
-v, --verbose... Enables verbose logging
-p, --png <PNG> Custom PNG icon sizes to generate. When set, the default icons are not generated
-h, --help Print help
-V, --version Print version
有关更多信息,请查看完整的 Tauri 图标指南。
completions
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri completions
yarn tauri completions
pnpm tauri completions
bunx tauri completions
cargo tauri completions
Usage: cargo-tauri completions [OPTIONS] --shell <SHELL>
Options:
-s, --shell <SHELL> Shell to generate a completion script for. [possible values: bash, elvish, fish, powershell, zsh]
-v, --verbose... Enables verbose logging
-o, --output <OUTPUT> Output file for the shell completions. By default the completions are printed to stdout
-h, --help Print help
-V, --version Print version
Tauri CLI 可以为 Bash、Zsh、PowerShell 和 Fish 生成 shell 自动补全功能。
以下是如何配置 Bash、Zsh 和 PowerShell 的说明。如果您遇到问题,请改用您 shell 的说明。请注意,出于安全原因,建议在执行生成的补全脚本之前检查它。
Bash
获取 Bash 自动补全文件并移动到已知文件夹
- npm
- Yarn
- pnpm
- Bun
- Cargo
npm run tauri completions -- --shell bash > tauri.sh
mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash
yarn tauri completions --shell bash > tauri.sh
mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash
pnpm tauri completions --shell bash > tauri.sh
mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash
bunx tauri completions --shell bash > tauri.sh
mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash
cargo tauri completions --shell bash > tauri.sh
mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash
通过将以下内容添加到 `.bashrc` 来加载自动补全脚本
source /usr/local/etc/bash_completion.d/tauri.bash
Zsh
获取 Zsh 自动补全文件并移动到已知文件夹
- npm
- Yarn
- pnpm
- Bun
- Cargo
npm run tauri completions -- --shell zsh > completions.zsh
mv completions.zsh $HOME/.completions/_tauri
yarn tauri completions --shell zsh > completions.zsh
mv completions.zsh $HOME/.completions/_tauri
pnpm tauri completions --shell zsh > completions.zsh
mv completions.zsh $HOME/.completions/_tauri
bunx tauri completions -- --shell zsh > completions.zsh
mv completions.zsh $HOME/.completions/_tauri
cargo tauri completions --shell zsh > completions.zsh
mv completions.zsh $HOME/.completions/_tauri
使用 fpath 添加以下内容到 `.zshrc` 来加载自动补全文件夹
fpath=(~/.completions $fpath)
autoload -U compinit
PowerShell
获取 PowerShell 自动补全文件并将其添加到 `$profile` 文件以在所有会话中执行它
- npm
- Yarn
- pnpm
- Bun
- Cargo
npm run tauri completions -- --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1")
Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"'
yarn tauri completions --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1")
Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"'
pnpm tauri completions --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1")
Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"'
bunx tauri completions -- --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1")
Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"'
cargo tauri completions --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1")
Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"'
version
- npm
- Yarn
- pnpm
- bun
- Cargo
npm run tauri --version
yarn tauri --version
pnpm tauri --version
bunx tauri --version
cargo tauri --version
Description
Returns the current version of tauri
此命令将显示 Tauri 的当前版本。
CLI 使用
通过此 完整指南 查看更多关于使用方法的信息。