是否可以为powershell脚本的参数指定HelpMessage
和基于注释的帮助内容而不用重复文本(DRY)?< / p>
# .SYNOPSIS
# a thing for testing help
[CmdletBinding()]
param (
# COMMENT-MESSAGE-HERE-NOT-DRY
[parameter(Mandatory=$true, HelpMessage="HELP-MESSAGE-HERE-NOT-DRY")]
$thing
)
echo $thing
~\Documents> .\erm.ps1
cmdlet erm.ps1 at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
thing: !?
HELP-MESSAGE-HERE-NOT-DRY
thing: oh well
oh well
~\Documents>
~\Documents> help .\erm.ps1 -detailed
...
PARAMETERS
-thing <Object>
COMMENT-MESSAGE-HERE-NOT-DRY
虽然许多人可能没有使用它,但我认为如果它在那里,人们可以找到它,我应该填充它。但我不想破坏可维护性。
我猜答案是否定的,但我想我会问。