11<#
2- . SYNOPSIS
3- Registers a command which can be executed in the host editor.
4-
5- . DESCRIPTION
6- Registers a command which can be executed in the host editor. This
7- command will be shown to the user either in a menu or command palette.
8- Upon invoking this command, either a function/cmdlet or ScriptBlock will
9- be executed depending on whether the -Function or -ScriptBlock parameter
10- was used when the command was registered.
11-
12- This command can be run multiple times for the same command so that its
13- details can be updated. However, re-registration of commands should only
14- be used for development purposes, not for dynamic behavior.
15-
16- . PARAMETER Name
17- Specifies a unique name which can be used to identify this command.
18- This name is not displayed to the user.
19-
20- . PARAMETER DisplayName
21- Specifies a display name which is displayed to the user.
22-
23- . PARAMETER Function
24- Specifies a function or cmdlet name which will be executed when the user
25- invokes this command. This function may take a parameter called $context
26- which will be populated with an EditorContext object containing information
27- about the host editor's state at the time the command was executed.
28-
29- . PARAMETER ScriptBlock
30- Specifies a ScriptBlock which will be executed when the user invokes this
31- command. This ScriptBlock may take a parameter called $context
32- which will be populated with an EditorContext object containing information
33- about the host editor's state at the time the command was executed.
34-
35- . PARAMETER SuppressOutput
36- If provided, causes the output of the editor command to be suppressed when
37- it is run. Errors that occur while running this command will still be
38- written to the host.
39-
40- . EXAMPLE
41- PS> Register-EditorCommand -Name "MyModule.MyFunctionCommand" -DisplayName "My function command" -Function Invoke-MyCommand -SuppressOutput
42-
43- . EXAMPLE
44- PS> Register-EditorCommand -Name "MyModule.MyScriptBlockCommand" -DisplayName "My ScriptBlock command" -ScriptBlock { Write-Output "Hello from my command!" }
45-
46- . LINK
47- Unregister-EditorCommand
2+ . EXTERNALHELP ..\PowerShellEditorServices.Commands-help.xml
483#>
494function Register-EditorCommand {
505 [CmdletBinding ()]
@@ -100,21 +55,7 @@ function Register-EditorCommand {
10055}
10156
10257<#
103- . SYNOPSIS
104- Unregisters a command which has already been registered in the host editor.
105-
106- . DESCRIPTION
107- Unregisters a command which has already been registered in the host editor.
108- An error will be thrown if the specified Name is unknown.
109-
110- . PARAMETER Name
111- Specifies a unique name which identifies a command which has already been registered.
112-
113- . EXAMPLE
114- PS> Unregister-EditorCommand -Name "MyModule.MyFunctionCommand"
115-
116- . LINK
117- Register-EditorCommand
58+ . EXTERNALHELP ..\PowerShellEditorServices.Commands-help.xml
11859#>
11960function Unregister-EditorCommand {
12061 [CmdletBinding ()]
@@ -138,3 +79,4 @@ function psedit {
13879 $psEditor.Workspace.OpenFile ($_.FullName )
13980 }
14081}
82+ Export-ModuleMember - Function psedit
0 commit comments