@tauri-apps/plugin-cli
解析来自您的命令行界面的参数。
接口
ArgMatch
自
2.0.0
属性
属性 | 类型 | 描述 | 定义在 |
---|---|---|---|
occurrences | number | 出现次数 | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L26 |
value | null | string | boolean | string [] | string 如果接受值 boolean 如果是标志 string[] 或 null 如果接受多个值 | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L22 |
CliMatches
自
2.0.0
属性
属性 | 类型 | 定义在 |
---|---|---|
args | Record <string , ArgMatch > | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L41 |
subcommand | null | SubcommandMatch | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L42 |
SubcommandMatch
自
2.0.0
属性
函数
getMatches()
function getMatches(): Promise<CliMatches>
解析提供给当前进程的参数,并使用在 tauri.cli
中定义的配置获取匹配项 tauri.conf.json
返回值
示例
import { getMatches } from '@tauri-apps/plugin-cli';const matches = await getMatches();if (matches.subcommand?.name === 'run') { // `./your-app run $ARGS` was executed const args = matches.subcommand?.matches.args if ('debug' in args) { // `./your-app run --debug` was executed }} else { const args = matches.args // `./your-app $ARGS` was executed}
自
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L66
© 2025 Tauri Contributors. CC-BY / MIT