Skip to content

Instantly share code, notes, and snippets.

@gerane
Created May 13, 2016 15:33
Show Gist options
  • Save gerane/f6b80bbe19c66b0b9de688fd23ea14a4 to your computer and use it in GitHub Desktop.
Save gerane/f6b80bbe19c66b0b9de688fd23ea14a4 to your computer and use it in GitHub Desktop.
function Get-CommandChoice
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[Array]$Array,
[Parameter(Mandatory=$true)]
[string]$caption,
[Parameter(Mandatory=$true)]
[string]$Message,
[int]$DefaultChoice = 0
)
$Choices = [System.Management.Automation.Host.ChoiceDescription[]] @($Array)
$Choice = $host.ui.PromptForChoice($Caption,$Message, $Choices,$DefaultChoice)
Return $Array[$Choice]
}
function Invoke-TestCommand {
$Extensions = Get-Childitem -path "$Env:USERPROFILE\.vscode-insiders\extensions\gerane*" -Directory
$Caption = "Please select a an Extension"
$Message = "Package.json will be launched"
$CommandChoice = Get-CommandChoice -Array $Extensions.Name -caption $Caption -Message $Message
$Package = "$Env:USERPROFILE\.vscode-insiders\extensions\$CommandChoice\package.json"
$psEditor.Workspace.OpenFile($Package)
}
Register-EditorCommand `
-Name "MyModule.OpenExtPackageJson" `
-DisplayName "Open Extension Package.json" `
-Function Invoke-TestCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment