[vcpkg] Initial commit of powershell integration

This commit is contained in:
Robert Schumacher 2017-10-14 01:45:28 -07:00
parent bea4c2ff49
commit fc1a24ad8b
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,31 @@
@{
# Script module or binary module file associated with this manifest.
ModuleToProcess = 'posh-vcpkg.psm1'
# Version number of this module.
ModuleVersion = '0.0.1'
# ID used to uniquely identify this module
GUID = '948f02ab-fc99-4a53-8335-b6556eef129b'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
FunctionsToExport = @('TabExpansion')
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess.
# This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData =
@{
PSData =
@{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('vcpkg', 'tab', 'tab-completion', 'tab-expansion', 'tabexpansion')
}
}
}

View File

@ -0,0 +1,39 @@
param()
if (Get-Module posh-vcpkg) { return }
if ($PSVersionTable.PSVersion.Major -lt 5) {
Write-Warning ("posh-vcpkg does not support PowerShell versions before 5.0.")
return
}
if (Test-Path Function:\TabExpansion) {
Rename-Item Function:\TabExpansion VcpkgTabExpansionBackup
}
function TabExpansion($line, $lastWord) {
$lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart()
switch -regex ($lastBlock) {
"^(?<vcpkgexe>(\./|\.\\|)vcpkg(\.exe|)) (?<remaining>.*)$"
{
& $matches['vcpkgexe'] autocomplete $matches['remaining']
return
}
# Fall back on existing tab expansion
default {
if (Test-Path Function:\VcpkgTabExpansionBackup) {
VcpkgTabExpansionBackup $line $lastWord
}
}
}
}
$exportModuleMemberParams = @{
Function = @(
'TabExpansion'
)
}
Export-ModuleMember @exportModuleMemberParams