Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
113 views
in Technique[技术] by (71.8m points)

How to hide "Helper" Functions in Powershell Modules

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

lists all functions I have in my module folder (e.g. get-foo and 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
question from:https://stackoverflow.com/questions/6032344/how-to-hide-helper-functions-in-powershell-modules

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

Then, export-modulemember *-* takes care of only exporting what you want to export.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...