shitbox/pkg/usr/share/pwsh/completions/_mountpoint.ps1

39 lines
2.1 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'mountpoint' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'mountpoint'
for ($i = 1; $i -lt $commandElements.Count; $i++) {
$element = $commandElements[$i]
if ($element -isnot [StringConstantExpressionAst] -or
$element.StringConstantType -ne [StringConstantType]::BareWord -or
$element.Value.StartsWith('-') -or
$element.Value -eq $wordToComplete) {
break
}
$element.Value
}) -join ';'
$completions = @(switch ($command) {
'mountpoint' {
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Show the major/minor numbers of the device that is mounted on the given directory.')
[CompletionResult]::new('--fs-devno', 'fs-devno', [CompletionResultType]::ParameterName, 'Show the major/minor numbers of the device that is mounted on the given directory.')
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'Show the major/minor numbers of the given blockdevice on standard output.')
[CompletionResult]::new('--devno', 'devno', [CompletionResultType]::ParameterName, 'Show the major/minor numbers of the given blockdevice on standard output.')
[CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Be quiet - dont print anything.')
[CompletionResult]::new('--quiet', 'quiet', [CompletionResultType]::ParameterName, 'Be quiet - dont print anything.')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
})
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}