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

46 lines
3.4 KiB
PowerShell

using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'umount' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'umount'
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) {
'umount' {
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Indicate that the actions should only be taken on filesystems of the specified type.')
[CompletionResult]::new('--types', 'types', [CompletionResultType]::ParameterName, 'Indicate that the actions should only be taken on filesystems of the specified type.')
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'All of the file systems described in /proc/mounts are unmounted. The proc filesystem is not unmounted.')
[CompletionResult]::new('--all', 'all', [CompletionResultType]::ParameterName, 'All of the file systems described in /proc/mounts are unmounted. The proc filesystem is not unmounted.')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Force an unmount (in case of an unreachable NFS system).')
[CompletionResult]::new('--force', 'force', [CompletionResultType]::ParameterName, 'Force an unmount (in case of an unreachable NFS system).')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Lazy unmount. Detach the filesystem from the fs hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore.')
[CompletionResult]::new('--lazy', 'lazy', [CompletionResultType]::ParameterName, 'Lazy unmount. Detach the filesystem from the fs hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore.')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Unmount without writing in /etc/mtab. This is the default action. This flag exists only for historical compatability.')
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'output a diagnostic for every file processed')
[CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'output a diagnostic for every file processed')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
})
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}