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

117 lines
8.1 KiB
PowerShell

using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'bootstrap' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'bootstrap'
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) {
'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
}
'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')
break
}
'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')
break
}
'bootstrap;manpages' {
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
break
}
'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')
break
}
'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
}
'bootstrap;help;all' {
break
}
'bootstrap;help;links' {
break
}
'bootstrap;help;manpages' {
break
}
'bootstrap;help;completions' {
break
}
'bootstrap;help;help' {
break
}
})
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}