Created
January 14, 2020 12:25
-
-
Save leonard84/3828a2584e6a3cbc30a90c44c86b191e to your computer and use it in GitHub Desktop.
A Module to make Jabba usage a bit nicer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Jabba-Use | |
{ | |
param( | |
[Parameter(Mandatory)] | |
[string]$Version | |
) | |
jabba use $Version | |
} | |
function Jabba-Install | |
{ | |
param( | |
[Parameter(Mandatory)] | |
[string]$Version | |
) | |
jabba install $Version | |
} | |
function Jabba-Uninstall | |
{ | |
param( | |
[Parameter(Mandatory)] | |
[string]$Version | |
) | |
jabba uninstall $Version | |
} | |
function Jabba-Which | |
{ | |
param( | |
[Parameter(Mandatory)] | |
[string]$Version | |
) | |
jabba which $Version | |
} | |
function Jabba-Ls { | |
jabba ls | |
} | |
function Jabba-LsRemote { | |
jabba ls-remote | |
} | |
function Jabba-Link { | |
param( | |
[Parameter(Mandatory)] | |
[string]$Name, | |
[Parameter()] | |
[string]$Path | |
) | |
jabba link $Name $Path | |
} | |
function Jabba-Unlink { | |
param( | |
[Parameter(Mandatory)] | |
[string]$Name | |
) | |
jabba unlink $Name | |
} | |
function Jabba-Alias { | |
param( | |
[Parameter(Mandatory)] | |
[string]$Name, | |
[Parameter()] | |
[string]$Version | |
) | |
jabba alias $Name $Version | |
} | |
function Jabba-Unalias { | |
param( | |
[Parameter(Mandatory)] | |
[string]$Name | |
) | |
jabba unalias $Name | |
} | |
function Jabba-Current { | |
jabba current | |
} | |
function Jabba-Deactivate { | |
jabba deactivate | |
} | |
$listInstalledVersions = { | |
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) | |
(jabba ls) | Where {$_ -like "$($wordToComplete)*"} | ForEach-Object { | |
New-Object System.Management.Automation.CompletionResult ( | |
$_, | |
$_, | |
'ParameterValue', | |
$_ | |
) | |
} | |
} | |
$listRemoteVersions = { | |
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) | |
(jabba ls-remote) | Where {$_ -like "$($wordToComplete)*"} | ForEach-Object { | |
New-Object System.Management.Automation.CompletionResult ( | |
$_, | |
$_, | |
'ParameterValue', | |
$_ | |
) | |
} | |
} | |
Register-ArgumentCompleter -CommandName Jabba-Use -ParameterName Version -ScriptBlock $listInstalledVersions | |
Register-ArgumentCompleter -CommandName Jabba-Uninstall -ParameterName Version -ScriptBlock $listInstalledVersions | |
Register-ArgumentCompleter -CommandName Jabba-Which -ParameterName Version -ScriptBlock $listInstalledVersions | |
Register-ArgumentCompleter -CommandName Jabba-Alias -ParameterName Version -ScriptBlock $listInstalledVersions | |
Register-ArgumentCompleter -CommandName Jabba-Install -ParameterName Version -ScriptBlock $listRemoteVersions | |
Export-ModuleMember -Function Jabba-Use | |
Export-ModuleMember -Function Jabba-Install | |
Export-ModuleMember -Function Jabba-Uninstall | |
Export-ModuleMember -Function Jabba-Which | |
Export-ModuleMember -Function Jabba-Ls | |
Export-ModuleMember -Function Jabba-LsRemote | |
Export-ModuleMember -Function Jabba-Link | |
Export-ModuleMember -Function Jabba-Unlink | |
Export-ModuleMember -Function Jabba-Alias | |
Export-ModuleMember -Function Jabba-Unalias | |
Export-ModuleMember -Function Jabba-Current | |
Export-ModuleMember -Function Jabba-Deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment