From 279384ee4a578a416004e9295835e30473fcb97e Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Fri, 15 Mar 2024 14:57:46 -0400 Subject: [PATCH] Allow passing show flag arguments with PowerShell completions --- extra/completion.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extra/completion.ps1 b/extra/completion.ps1 index be50bde..9b96a13 100644 --- a/extra/completion.ps1 +++ b/extra/completion.ps1 @@ -1,7 +1,7 @@ function MUTNEntryCompleter { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) - $entryPath = (Resolve-Path '~/.local/share/libmutton').Path # UNIX testing - #$entryPath = (Resolve-Path '~/AppData/Local/libmutton/entries').Path + #$entryPath = (Resolve-Path '~/.local/share/libmutton').Path # UNIX testing + $entryPath = (Resolve-Path '~/AppData/Local/libmutton/entries').Path $entryNames = If (Test-Path $entryPath) {(Get-ChildItem -Path $entryPath -Recurse).FullName.Substring($entryPath.Length) -replace '\\', '/' -replace ' ', '` '} $entryNames | Where-Object { $_ -like "$wordToComplete*" } } @@ -38,9 +38,12 @@ function mutn { [Parameter(Position = 2)] [ArgumentCompleter({ MUTNOptionCompleter @args })] - [string]$option + [string]$option, + + [Parameter(Position = 3)] + [string]$potentialShowFlag ) - Invoke-Expression -Command ('/usr/local/bin/mutn ' + ($entry -replace ' ', '` '), $argument, ($option -replace ':', '-')).Trim() # UNIX testing - #Invoke-Expression -Command ('mutn.exe ' + ($entry -replace ' ', '` '), $argument, $option).Trim() + #Invoke-Expression -Command ('/usr/local/bin/mutn ' + ($entry -replace ' ', '` '), $argument, ($option -replace ':', '-'), ($potentialShowFlag -replace ':', '-')).Trim() # UNIX testing + Invoke-Expression -Command ('./mutn.exe ' + ($entry -replace ' ', '` '), $argument, $option, $potentialShowFlag).Trim() }