Edit-MyScript supports -TypeData editing

This commit is contained in:
lksz 2021-05-27 12:47:27 -04:00
parent 84d533a210
commit 6b8bd711af
1 changed files with 44 additions and 0 deletions

View File

@ -21,6 +21,32 @@
[Packagesz]::_GetValidValues($wordToComplete,$NotAll,$true)
})]
[string]$Package,
[ArgumentCompleter({ param (
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters
)
$local:NotAll = $true
if( $fakeBoundParameters.ContainsKey("All") ) { $NotAll = -not $fakeBoundParameters.All }
$( (,(
Get-MyPackages -Force |
ForEach-Object { Join-Path (Join-Path $MyPSScriptRoot $_) $(Join-Path "profile.d" "*.format.ps1xml") } |
Where-Object { Test-Path $_ } |
Get-Item |
ForEach-Object {
"$( $_ |
Select-Object -ExpandProperty Directory |
Select-Object -ExpandProperty Parent |
Select-Object -ExpandProperty Name
):$($_.Name -replace '\.format\.ps1xml$','')" # -replace ':TypeData$',''
}
)) + (
[Packagesz]::_GetValidValues($wordToComplete,$NotAll,$true))
) | Select-Object -Unique
})]
[string[]]$TypeData,
[switch]$ForceImport,
[switch]$All,
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
@ -70,6 +96,24 @@ foreach( $local:p in $ScriptName ) {
$ScriptPaths += $sp
}
foreach( $local:t in $TypeData ) {
$local:pkgName = $t
$local:fileBaseName = 'TypeData'
if( $t.Contains(':') ) {
$pkgName = $t -Split ':' | Select-Object -First 1
$fileBaseName = $t -Split ':' | Select-Object -Skip 1 -First 1
}
$fileBaseName = $fileBaseName -replace '\.format\.ps1xml$',''
Get-Path $(
Join-Path $(Join-Path $EditRootPath $pkgName) $(Join-Path "profile.d" "$fileBaseName.format.ps1xml")
) |
Where-Object { $_ } |
ForEach-Object {
$ScriptPaths += $_
}
}
if( -not $ScriptPaths ) {
$ScriptPaths += $EditRootPath
}