Update completions

This commit is contained in:
Félix Saparelli 2022-07-08 02:14:23 +12:00
parent 8e61f053d2
commit 61baabdc6a
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
5 changed files with 22 additions and 14 deletions

View File

@ -12,7 +12,8 @@ Register-ArgumentCompleter -Native -CommandName 'cargo-watch' -ScriptBlock {
$element = $commandElements[$i]
if ($element -isnot [StringConstantExpressionAst] -or
$element.StringConstantType -ne [StringConstantType]::BareWord -or
$element.Value.StartsWith('-')) {
$element.Value.StartsWith('-') -or
$element.Value -eq $wordToComplete) {
break
}
$element.Value
@ -24,7 +25,7 @@ Register-ArgumentCompleter -Native -CommandName 'cargo-watch' -ScriptBlock {
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('watch', 'watch', [CompletionResultType]::ParameterValue, 'Watches over your Cargo projects source')
[CompletionResult]::new('watch', 'watch', [CompletionResultType]::ParameterValue, 'Watch your Cargo-based project and run commands when files change')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
@ -42,7 +43,7 @@ Register-ArgumentCompleter -Native -CommandName 'cargo-watch' -ScriptBlock {
[CompletionResult]::new('--package', 'package', [CompletionResultType]::ParameterName, 'Reserved for workspace support')
[CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Watch specific file(s) or folder(s)')
[CompletionResult]::new('--watch', 'watch', [CompletionResultType]::ParameterName, 'Watch specific file(s) or folder(s)')
[CompletionResult]::new('--use-shell', 'use-shell', [CompletionResultType]::ParameterName, 'Shell to use for the command, or `none` for direct execution')
[CompletionResult]::new('--use-shell', 'use-shell', [CompletionResultType]::ParameterName, 'Shell to use for --shell commands, or `none` for direct execution')
[CompletionResult]::new('-C', 'C', [CompletionResultType]::ParameterName, 'Change working directory of the command')
[CompletionResult]::new('--workdir', 'workdir', [CompletionResultType]::ParameterName, 'Change working directory of the command')
[CompletionResult]::new('--testing-only--once', 'testing-only--once', [CompletionResultType]::ParameterName, 'testing-only--once')

View File

@ -43,7 +43,7 @@ _arguments "${_arguments_options[@]}" \
'*--package=[Reserved for workspace support]:spec: ' \
'*-w+[Watch specific file(s) or folder(s)]:path: ' \
'*--watch=[Watch specific file(s) or folder(s)]:path: ' \
'--use-shell=[Shell to use for the command, or `none` for direct execution]:shell: ' \
'*--use-shell=[Shell to use for --shell commands, or `none` for direct execution]:shell: ' \
'-C+[Change working directory of the command]:path: ' \
'--workdir=[Change working directory of the command]:path: ' \
'--testing-only--once[]' \
@ -84,7 +84,7 @@ esac
(( $+functions[_cargo-watch_commands] )) ||
_cargo-watch_commands() {
local commands; commands=(
'watch:Watches over your Cargo projects source' \
'watch:Watch your Cargo-based project and run commands when files change' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'cargo-watch commands' commands "$@"

View File

@ -22,7 +22,7 @@ set edit:completion:arg-completer[cargo-watch] = {|@words|
cand --help 'Print help information'
cand -V 'Print version information'
cand --version 'Print version information'
cand watch 'Watches over your Cargo projects source'
cand watch 'Watch your Cargo-based project and run commands when files change'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'cargo-watch;watch'= {
@ -39,7 +39,7 @@ set edit:completion:arg-completer[cargo-watch] = {|@words|
cand --package 'Reserved for workspace support'
cand -w 'Watch specific file(s) or folder(s)'
cand --watch 'Watch specific file(s) or folder(s)'
cand --use-shell 'Shell to use for the command, or `none` for direct execution'
cand --use-shell 'Shell to use for --shell commands, or `none` for direct execution'
cand -C 'Change working directory of the command'
cand --workdir 'Change working directory of the command'
cand --testing-only--once 'testing-only--once'

View File

@ -4,11 +4,12 @@ const completion: Fig.Spec = {
subcommands: [
{
name: "watch",
description: "Watches over your Cargo projects source",
description: "Watch your Cargo-based project and run commands when files change",
options: [
{
name: "--features",
description: "Feature(s) passed to cargo invocations",
isRepeatable: true,
args: {
name: "features",
isOptional: true,
@ -17,6 +18,7 @@ const completion: Fig.Spec = {
{
name: ["-x", "--exec"],
description: "Cargo command(s) to execute on changes",
isRepeatable: true,
args: {
name: "cmd-cargo",
isVariadic: true,
@ -26,6 +28,7 @@ const completion: Fig.Spec = {
{
name: ["-s", "--shell"],
description: "Shell command(s) to execute on changes",
isRepeatable: true,
args: {
name: "cmd-shell",
isVariadic: true,
@ -43,6 +46,7 @@ const completion: Fig.Spec = {
{
name: ["-i", "--ignore"],
description: "Ignore a path pattern",
isRepeatable: true,
args: {
name: "ignores",
isVariadic: true,
@ -52,6 +56,8 @@ const completion: Fig.Spec = {
{
name: ["-p", "--package"],
description: "Reserved for workspace support",
hidden: true,
isRepeatable: true,
args: {
name: "packages-specs",
isVariadic: true,
@ -61,6 +67,7 @@ const completion: Fig.Spec = {
{
name: ["-w", "--watch"],
description: "Watch specific file(s) or folder(s)",
isRepeatable: true,
args: {
name: "watch",
isVariadic: true,
@ -69,9 +76,11 @@ const completion: Fig.Spec = {
},
{
name: "--use-shell",
description: "Shell to use for the command, or `none` for direct execution",
description: "Shell to use for --shell commands, or `none` for direct execution",
isRepeatable: true,
args: {
name: "shell",
name: "use-shell",
isVariadic: true,
isOptional: true,
},
},
@ -160,8 +169,6 @@ const completion: Fig.Spec = {
{
name: "help",
description: "Print this message or the help of the given subcommand(s)",
options: [
],
args: {
name: "subcommand",
isOptional: true,

View File

@ -1,6 +1,6 @@
complete -c cargo-watch -n "__fish_use_subcommand" -s h -l help -d 'Print help information'
complete -c cargo-watch -n "__fish_use_subcommand" -s V -l version -d 'Print version information'
complete -c cargo-watch -n "__fish_use_subcommand" -f -a "watch" -d 'Watches over your Cargo projects source'
complete -c cargo-watch -n "__fish_use_subcommand" -f -a "watch" -d 'Watch your Cargo-based project and run commands when files change'
complete -c cargo-watch -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -l features -d 'Feature(s) passed to cargo invocations' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s x -l exec -d 'Cargo command(s) to execute on changes' -r
@ -9,7 +9,7 @@ complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s d -l delay -d
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s i -l ignore -d 'Ignore a path pattern' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s p -l package -d 'Reserved for workspace support' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s w -l watch -d 'Watch specific file(s) or folder(s)' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -l use-shell -d 'Shell to use for the command, or `none` for direct execution' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -l use-shell -d 'Shell to use for --shell commands, or `none` for direct execution' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s C -l workdir -d 'Change working directory of the command' -r
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -l testing-only--once
complete -c cargo-watch -n "__fish_seen_subcommand_from watch" -s c -l clear -d 'Clear the screen before each run'