-h
パラメータと同様に値を渡さずに動作させ たい -h
: ただし、他のものはそのままにしておきたい... つまり、パラメータにエイリアスを設定し、価値。
Param(
$BadParam,
[alias("h")][String]$Help,
[alias("s")][String]$Server,
[alias("d")][String]$DocRoot,
[alias("c")][String]$Commit,
[alias("b")][String]$Branch
)
例(より良いものがない場合):
if(!$Help)
{
Write-Host "Here's the menu for how it works bro."
}
if($Help)
{
Write-Host "Here's more info on that particular thing from the menu."
}
これがシェルでどのように動作すると予想されるか:
-> script.ps1 -s test -h
-> Here's the menu for how it works bro.
-> script.ps1 -s test -h server
-> Here's more info on that particular thing from the menu.
-> script.ps1 -s -h server
-> You are missing a value for -e.