PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

Add blocklist/inclusion list for editor commands

Open gerane opened this issue 8 years ago • 2 comments

Eventually there is going to be a need to ignore certain Commands or Modules when PSES Registers Commands.

Here are the ideas I have had.

  • Block all Registering from outside of Profile
  • Block all Registering from Blacklisted Modules.
  • Only Allow Registering from Whitelisted Modules
  • Only Allow Registering Whitelisted Commands

You can currently do something like the following:

# Microsoft.VSCode_profile.ps1
Import-Module Blah1
Import-Module Blah2
Import-Module Blah3
Import-Module Blah4
Import-Module Blah5

# Do All The Things Here

Unregister-EditorCommand -Name Command1FromBlah1
Unregister-EditorCommand -Name Command2FromBlah1
Unregister-EditorCommand -Name Command1FromBlah2
Unregister-EditorCommand -Name Command2FromBlah2
Unregister-EditorCommand -Name Command3FromBlah3
Unregister-EditorCommand -Name Command1FromBlah4
Unregister-EditorCommand -Name Command1FromBlah5
Unregister-EditorCommand -Name Command2FromBlah5
Unregister-EditorCommand -Name Command3FromBlah5

However, this would quickly become a headache and hard to maintain if a Module is regularly adding commands etc.

gerane avatar May 27 '16 14:05 gerane

Yep, I've thought about this too. I think it'd be easier to blacklist specific modules and commands than having to maintain a whitelist, though I suppose a whitelist makes sense if you know you only ever want to use one or two modules.

daviwil avatar May 27 '16 14:05 daviwil

Yeah, I think a blacklist that also allows for entire module is for sure needed. The others I wanted to mention to see what others might think.

gerane avatar May 27 '16 14:05 gerane