39 lines
2.1 KiB
PowerShell
39 lines
2.1 KiB
PowerShell
|
||
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 - don’t print anything.')
|
||
[CompletionResult]::new('--quiet', 'quiet', [CompletionResultType]::ParameterName, 'Be quiet - don’t 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
|
||
}
|