PowerShell cmdlet 参数值选项卡完成 [英] PowerShell cmdlet parameter value tab completion

查看:60
本文介绍了PowerShell cmdlet 参数值选项卡完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 PowerShell 3.0 中为 PowerShell 函数或 cmdlet(如 Get-Service 和 Get-Process)实现参数选项卡补全?

How do you implement the parameter tab completion for PowerShell functions or cmdlets like Get-Service and Get-Process in PowerShell 3.0?

我意识到 ValidateSet 适用于已知列表,但我想要按需生成列表.

I realise ValidateSet works for a known list, but I want to generate the list on demand.

Adam Driscoll 暗示这是可能的 cmdlet,但遗憾的是没有详细说明.

Adam Driscoll hints that it is possible for cmdlets but unfortunately hasn't elaborated.

Trevor Sullivan 显示一种用于函数的技术,但据我所知,他的代码仅在定义函数时生成列表.

Trevor Sullivan shows a technique for functions, but as I understand it, his code only generates the list at the time the function is defined.

推荐答案

查看 github 上的 TabExpansionPlusPlus 模块,该模块由前 PowerShell 团队魔术师编写.

Check the TabExpansionPlusPlus module on github, written by a former PowerShell team magician.

https://github.com/lzybkr/TabExpansionPlusPlus#readme

这篇关于PowerShell cmdlet 参数值选项卡完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆