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

245 lines
19 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 'utilbox' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'utilbox'
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) {
'utilbox' {
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('bootstrap', 'bootstrap', [CompletionResultType]::ParameterValue, 'Install shitbox into the filesystem')
[CompletionResult]::new('clear', 'clear', [CompletionResultType]::ParameterValue, 'clear the terminal''s screen')
[CompletionResult]::new('mountpoint', 'mountpoint', [CompletionResultType]::ParameterValue, 'see if a directory or file is a mountpoint')
[CompletionResult]::new('swaplabel', 'swaplabel', [CompletionResultType]::ParameterValue, 'set the label of a swap filesystem')
[CompletionResult]::new('swapoff', 'swapoff', [CompletionResultType]::ParameterValue, 'disable devices and files for paging and swapping')
[CompletionResult]::new('umount', 'umount', [CompletionResultType]::ParameterValue, 'unmount filesystems')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'utilbox;bootstrap' {
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'The directory path under which to install')
[CompletionResult]::new('--prefix', 'prefix', [CompletionResultType]::ParameterName, 'The directory path under which to install')
[CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'Use /usr')
[CompletionResult]::new('--usr', 'usr', [CompletionResultType]::ParameterName, 'Use /usr')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Install soft links instead of hardlinks')
[CompletionResult]::new('--soft', 'soft', [CompletionResultType]::ParameterName, 'Install soft links instead of hardlinks')
[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')
[CompletionResult]::new('all', 'all', [CompletionResultType]::ParameterValue, 'Install everything')
[CompletionResult]::new('links', 'links', [CompletionResultType]::ParameterValue, 'Install links for each applet')
[CompletionResult]::new('manpages', 'manpages', [CompletionResultType]::ParameterValue, 'Install Unix man pages')
[CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Install shell completions')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'utilbox;bootstrap;all' {
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Install soft links instead of hardlinks')
[CompletionResult]::new('--soft', 'soft', [CompletionResultType]::ParameterName, 'Install soft links instead of hardlinks')
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Install completions for all supported shells')
[CompletionResult]::new('--all', 'all', [CompletionResultType]::ParameterName, 'Install completions for all supported shells')
[CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Bash shell completions')
[CompletionResult]::new('--bash', 'bash', [CompletionResultType]::ParameterName, 'Bash shell completions')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Fish shell completions')
[CompletionResult]::new('--fish', 'fish', [CompletionResultType]::ParameterName, 'Fish shell completions')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Nushell completions')
[CompletionResult]::new('--nu', 'nu', [CompletionResultType]::ParameterName, 'Nushell completions')
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'PowerShell completions')
[CompletionResult]::new('--pwsh', 'pwsh', [CompletionResultType]::ParameterName, 'PowerShell completions')
[CompletionResult]::new('-z', 'z', [CompletionResultType]::ParameterName, 'Zshell completions')
[CompletionResult]::new('--zsh', 'zsh', [CompletionResultType]::ParameterName, 'Zshell completions')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;bootstrap;links' {
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Install soft links instead of hardlinks')
[CompletionResult]::new('--soft', 'soft', [CompletionResultType]::ParameterName, 'Install soft links instead of hardlinks')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;bootstrap;manpages' {
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;bootstrap;completions' {
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Install completions for all supported shells')
[CompletionResult]::new('--all', 'all', [CompletionResultType]::ParameterName, 'Install completions for all supported shells')
[CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Bash shell completions')
[CompletionResult]::new('--bash', 'bash', [CompletionResultType]::ParameterName, 'Bash shell completions')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Fish shell completions')
[CompletionResult]::new('--fish', 'fish', [CompletionResultType]::ParameterName, 'Fish shell completions')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Nushell completions')
[CompletionResult]::new('--nu', 'nu', [CompletionResultType]::ParameterName, 'Nushell completions')
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'PowerShell completions')
[CompletionResult]::new('--pwsh', 'pwsh', [CompletionResultType]::ParameterName, 'PowerShell completions')
[CompletionResult]::new('-z', 'z', [CompletionResultType]::ParameterName, 'Zshell completions')
[CompletionResult]::new('--zsh', 'zsh', [CompletionResultType]::ParameterName, 'Zshell completions')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;bootstrap;help' {
[CompletionResult]::new('all', 'all', [CompletionResultType]::ParameterValue, 'Install everything')
[CompletionResult]::new('links', 'links', [CompletionResultType]::ParameterValue, 'Install links for each applet')
[CompletionResult]::new('manpages', 'manpages', [CompletionResultType]::ParameterValue, 'Install Unix man pages')
[CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Install shell completions')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'utilbox;bootstrap;help;all' {
break
}
'utilbox;bootstrap;help;links' {
break
}
'utilbox;bootstrap;help;manpages' {
break
}
'utilbox;bootstrap;help;completions' {
break
}
'utilbox;bootstrap;help;help' {
break
}
'utilbox;clear' {
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;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'')')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;swaplabel' {
[CompletionResult]::new('-L', 'L', [CompletionResultType]::ParameterName, 'set the label')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'set the label')
[CompletionResult]::new('--label', 'label', [CompletionResultType]::ParameterName, 'set the label')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;swapoff' {
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Disable swapping on all known swap devices and files as found in /etc/fstab.')
[CompletionResult]::new('--all', 'all', [CompletionResultType]::ParameterName, 'Disable swapping on all known swap devices and files as found in /etc/fstab.')
[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')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
'utilbox;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
}
'utilbox;help' {
[CompletionResult]::new('bootstrap', 'bootstrap', [CompletionResultType]::ParameterValue, 'Install shitbox into the filesystem')
[CompletionResult]::new('clear', 'clear', [CompletionResultType]::ParameterValue, 'clear the terminal''s screen')
[CompletionResult]::new('mountpoint', 'mountpoint', [CompletionResultType]::ParameterValue, 'see if a directory or file is a mountpoint')
[CompletionResult]::new('swaplabel', 'swaplabel', [CompletionResultType]::ParameterValue, 'set the label of a swap filesystem')
[CompletionResult]::new('swapoff', 'swapoff', [CompletionResultType]::ParameterValue, 'disable devices and files for paging and swapping')
[CompletionResult]::new('umount', 'umount', [CompletionResultType]::ParameterValue, 'unmount filesystems')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'utilbox;help;bootstrap' {
[CompletionResult]::new('all', 'all', [CompletionResultType]::ParameterValue, 'Install everything')
[CompletionResult]::new('links', 'links', [CompletionResultType]::ParameterValue, 'Install links for each applet')
[CompletionResult]::new('manpages', 'manpages', [CompletionResultType]::ParameterValue, 'Install Unix man pages')
[CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Install shell completions')
break
}
'utilbox;help;bootstrap;all' {
break
}
'utilbox;help;bootstrap;links' {
break
}
'utilbox;help;bootstrap;manpages' {
break
}
'utilbox;help;bootstrap;completions' {
break
}
'utilbox;help;clear' {
break
}
'utilbox;help;mountpoint' {
break
}
'utilbox;help;swaplabel' {
break
}
'utilbox;help;swapoff' {
break
}
'utilbox;help;umount' {
break
}
'utilbox;help;help' {
break
}
})
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}