如何让C#Cmdlet参数HelpMessage显示在`Get-Help`中
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何让C#Cmdlet参数HelpMessage显示在`Get-Help`中,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1511字,纯文字阅读大概需要3分钟。
内容图文
![如何让C#Cmdlet参数HelpMessage显示在`Get-Help`中](/upload/InfoBanner/zyjiaocheng/809/35da39ceb6984252a2f83845b3019ebc.jpg)
我已经启动了PowerShell cmdlet,并希望为参数提供帮助消息.我已经尝试过使用ParameterAttribute.HelpMessage:
[Cmdlet(VerbsCommon.Get, "Workspace", SupportsShouldProcess = true)]
public class GetWorkspace : PSCmdlet
{
[Parameter(
Mandatory = true,
Position = 1,
HelpMessage = "The path to the root directory of the workspace.")]
public string Path { get; set; }
protected override void ProcessRecord()
{
base.ProcessRecord();
}
}
但是,当我使用PowerShell Get-Help命令时,它不会显示参数的HelpMessage:
get-help Get-Workspace -det
NAME
Get-Workspace
SYNTAX
Get-Workspace [-Path] <string> [-WhatIf] [-Confirm] [<CommonParameters>]
PARAMETERS
-Confirm
-Path <string>
-WhatIf
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
ALIASES
None
REMARKS
None
在PowerShell脚本中编写cmdlet时,我可以使用以下语法为参数添加帮助消息:
<#
.Parameter Path
The local path to the root folder of the workspace.
#>
但是C#cmdlet中的等价物是什么?
解决方法:
你这样做是绝对正确的!
您只需要检查-Full视图或使用-Parameter获取特定参数的帮助:
PS C:\> Get-Help Get-Workspace -Parameter Path
-Path <string>
The path to the root directory of the workspace.
Required? true
Position? 1
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
内容总结
以上是互联网集市为您收集整理的如何让C#Cmdlet参数HelpMessage显示在`Get-Help`中全部内容,希望文章能够帮你解决如何让C#Cmdlet参数HelpMessage显示在`Get-Help`中所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。