W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
允許列表對(duì)象有一個(gè)字段,用于定義可以使用的 CLI 數(shù)組。
每個(gè)CLI都是一個(gè)配置對(duì)象。shell
scope
{ name: string, cmd: string, sidecar?: bool, args?: boolean | Arg[] }
name
:命令的唯一標(biāo)識(shí)符,傳遞給 Command 構(gòu)造函數(shù)。
如果是 sidecar,則此值必須是 上定義的值。tauri.conf.json > tauri > bundle > externalBin
cmd
:在此配置上執(zhí)行的程序。如果是 sidecar,則忽略此值。
sidecar
:對(duì)象是配置挎斗程序還是系統(tǒng)程序。
args
:可以傳遞給程序的參數(shù)。默認(rèn)情況下,不允許使用任何參數(shù)。
true
表示允許任何參數(shù)列表。
false
表示不允許任何參數(shù)。
{ validator: string }
命令行界面:git commit -m "the commit message"
配置:
{
"scope": [
{
"name": "run-git-commit",
"cmd": "git",
"args": ["commit", "-m", { "validator": "\\S+" }]
}
]
}
用法:
import { Command } from '@tauri-apps/api/shell'
new Command('run-git-commit', ['commit', '-m', 'the commit message'])
嘗試使用未在作用域上配置的程序執(zhí)行任何 API,會(huì)導(dǎo)致由于拒絕訪問而拒絕承諾。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: