mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-14 05:28:01 +08:00
[vcpkg] Initial commit of powershell integration
This commit is contained in:
parent
bea4c2ff49
commit
fc1a24ad8b
31
scripts/posh-vcpkg/0.0.1/posh-vcpkg.psd1
Normal file
31
scripts/posh-vcpkg/0.0.1/posh-vcpkg.psd1
Normal 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')
|
||||
}
|
||||
}
|
||||
|
||||
}
|
39
scripts/posh-vcpkg/0.0.1/posh-vcpkg.psm1
Normal file
39
scripts/posh-vcpkg/0.0.1/posh-vcpkg.psm1
Normal 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
|
Loading…
x
Reference in New Issue
Block a user