如何隐藏“助手" Powershell模块中的功能 [英] How to hide "Helper" Functions in Powershell Modules
问题描述
我有一个模块xy,它具有一些针对最终用户的功能以及一些由功能而非最终用户调用的内部帮助程序功能.
I have a module xy which has several functions for the end user and several internal helper functions called by functions but not by the end user.
Get-Command -Module xy -CommandType function
列出我模块文件夹中的所有功能(例如get-foo
和get-foo_helper
)
lists all functions I have in my module folder (e.g. get-foo
and get-foo_helper
)
有没有办法向正在使用的最终用户隐藏get-foo_helper
功能:
Is there a way to hide get-foo_helper
function from the end user who is using:
Get-Command -Module tcaps -CommandType function
推荐答案
我要做的一件事是对我要导出的函数使用动词-名词命名约定,但在辅助函数中省略了连字符.
One thing I have done is use the verb-noun naming convention for functions I want to export, but leave out the hyphen in helper functions.
然后,export-modulemember *-*
仅负责导出您要导出的内容.
Then, export-modulemember *-*
takes care of only exporting what you want to export.
这篇关于如何隐藏“助手" Powershell模块中的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!