跳到内容
Tauri

@tauri-apps/plugin-cli

从命令行界面解析参数。

2.0.0

属性类型描述定义于
occurrences数字出现次数来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L26
valuenull | string | boolean | string[]如果接收值,则为字符串;如果为标志,则为布尔值;如果接收多个值,则为字符串数组或 null。来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L22

2.0.0

属性类型定义于
argsRecord<string, ArgMatch>来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L41
subcommandnull | SubcommandMatch来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L42

2.0.0

属性类型定义于
matchesCliMatches来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L34
namestring来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L33

function getMatches(): Promise<CliMatches>

解析提供给当前进程的参数,并使用 tauri.conf.jsontauri.cli 定义的配置获取匹配项。

Promise<CliMatches>

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

来源https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/cli/guest-js/index.ts#L66


© 2025 Tauri 贡献者。CC-BY / MIT