如何在环境中启用 -one?如果我未指定“-one”,则它最终会出现在 opts 字符串中,或者会被忽略。
function test-run {
Param (
[switch]$one = $false,
[switch]$two = $false,
[switch]$tre = $false,
[string]$branch = "release",
[int]$forkid = -1,
[string]$opts = ""
)
"one: $one, two: $two, tre: $tre" | Out-Host
"branch: $branch, forkid: $forkid, opts: $opts" | Out-Host
}
$env:setupflag = "-one"
test-run $env:setupflag -two -tre -branch "test" -forkid 0 -opts ""
测试参数
一:False,二:True,tre:True
分支:测试,forkid:0,opts: