Skip to content

Commit

Permalink
[vcpkg] Initial commit of powershell integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Oct 14, 2017
1 parent bea4c2f commit fc1a24a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/posh-vcpkg/0.0.1/posh-vcpkg.psd1
Original file line number Diff line number Diff line change
@@ -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')
}
}

}
39 changes: 39 additions & 0 deletions scripts/posh-vcpkg/0.0.1/posh-vcpkg.psm1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fc1a24a

Please sign in to comment.