Honor required parameters in completions for builtins

This adds the -r (or -x) flag to completions of builtins' options that have a required_argument.
This commit is contained in:
Johannes Altmanninger 2019-09-24 07:43:38 +02:00 committed by David Adam
parent 8230755bfd
commit 2dbbaa6a97
7 changed files with 22 additions and 22 deletions

View file

@ -50,8 +50,8 @@ complete -c bind -s f -l function-names -d 'Print names of available functions'
complete -c bind -s h -l help -d "Display help and exit"
complete -c bind -s k -l key -d 'Specify key name, not sequence'
complete -c bind -s K -l key-names -d 'Print names of available keys'
complete -c bind -s M -l mode -d 'Specify the bind mode that the bind is used in'
complete -c bind -s m -l sets-mode -d 'Change current mode after bind is executed'
complete -c bind -s M -l mode -d 'Specify the bind mode that the bind is used in' -xa '(bind -L)'
complete -c bind -s m -l sets-mode -d 'Change current mode after bind is executed' -xa '(bind -L)'
complete -c bind -s L -l list-modes -d 'Display a list of defined bind modes'
complete -c bind -n __fish_bind_test1 -a '(bind --key-names)' -d 'Key name' -x

View file

@ -1,20 +1,20 @@
# Completions for complete
complete -c complete -s c -l command -d "Command to add completion to" -r
complete -c complete -s p -l path -d "Path to add completion to"
complete -c complete -s s -l short-option -d "POSIX-style short option to complete"
complete -c complete -s l -l long-option -d "GNU-style long option to complete"
complete -c complete -s o -l old-option -d "Old style long option to complete"
complete -c complete -s p -l path -d "Path to add completion to" -r
complete -c complete -s s -l short-option -d "POSIX-style short option to complete" -x
complete -c complete -s l -l long-option -d "GNU-style long option to complete" -x
complete -c complete -s o -l old-option -d "Old style long option to complete" -x
complete -c complete -s f -l no-files -d "Don't use file completion"
complete -c complete -s r -l require-parameter -d "Require parameter"
complete -c complete -s x -l exclusive -d "Require parameter and don\'t use file completion"
complete -c complete -s a -l arguments -d "Space-separated list of possible option arguments"
complete -c complete -s d -l description -d "Description of completion"
complete -c complete -s a -l arguments -d "Space-separated list of possible option arguments" -x
complete -c complete -s d -l description -d "Description of completion" -x
complete -c complete -s e -l erase -d "Remove completion"
complete -c complete -s h -l help -d "Display help and exit"
complete -c complete -s C -l do-complete -d "Print completions for a commandline specified as a parameter"
complete -c complete -s n -l condition -d "Completion only used if command has zero exit status" -r
complete -c complete -s w -l wraps -d "Inherit completions from specified command"
complete -c complete -s n -l condition -d "Completion only used if command has zero exit status" -x
complete -c complete -s w -l wraps -d "Inherit completions from specified command" -r
# Deprecated options

View file

@ -6,6 +6,6 @@ complete -c function -s p -l on-process-exit -d "Make the function a process exi
complete -c function -s s -l on-signal -d "Make the function a signal event handler" -x
complete -c function -s v -l on-variable -d "Make the function a variable update event handler" -x
complete -c function -s e -l on-event -d "Make the function a generic event handler" -xa 'fish_prompt fish_command_not_found'
complete -c function -s a -l argument-names -d "Specify named arguments"
complete -c function -s a -l argument-names -d "Specify named arguments" -x
complete -c function -s S -l no-scope-shadowing -d "Do not shadow variable scope of calling function"
complete -c function -s w -l wraps -d "Inherit completions from the given command"
complete -c function -s w -l wraps -d "Inherit completions from the given command" -r

View file

@ -13,7 +13,7 @@ complete -c history -n '__fish_seen_subcommand_from search delete' \
complete -c history -n '__fish_seen_subcommand_from search delete' \
-s C -l case-sensitive -d "Match items in a case-sensitive manner"
complete -c history -n '__fish_seen_subcommand_from search' \
-s n -l max -d "Limit output to the first 'n' matches"
-s n -l max -d "Limit output to the first 'n' matches" -x
# We don't include a completion for the "save" subcommand because it should not be used
# interactively.

View file

@ -1,2 +1,2 @@
complete -f -c math -r
complete -f -c math -s s -l scale -r
complete -f -c math -s s -l scale -r -x

View file

@ -6,10 +6,10 @@ complete -c read -s l -l local -d "Make variable scope local"
complete -c read -s U -l universal -d "Make variable scope universal, i.e. share variable with all the users fish processes on this computer"
complete -c read -s u -l unexport -d "Do not export variable to subprocess"
complete -c read -s m -l mode-name -d "Name to load/save history under" -r -a "read fish"
complete -c read -s c -l command -d "Initial contents of read buffwhen reading interactively"
complete -c read -s c -l command -d "Initial contents of read buffer when reading interactively" -r
complete -c read -s S -l shell -d "Use syntax highlighting, tab completions and command termination suitable for entering shellscript code"
complete -c read -s s -l silent -d "Secure mode: mask characters at the command line (suitable for passwords)"
complete -c read -s n -l nchars -d "Read the specified number of characters"
complete -c read -s n -l nchars -d "Read the specified number of characters" -x
complete -c read -s a -l array -d "Store the results as an array"
complete -c read -s R -l right-prompt -d "Set right-hand prompt command" -x
complete -c read -s z -l null -d "Use NUL character as line terminator"

View file

@ -6,8 +6,8 @@ complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "lower"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "upper"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "length"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "sub"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] sub" -s s -l start -a "(seq 1 10)"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] sub" -s l -l length -a "(seq 1 10)"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] sub" -s s -l start -xa "(seq 1 10)"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] sub" -s l -l length -xa "(seq 1 10)"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "split"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "split0"
complete -x -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr split0\?\$ -- (commandline -opc)[2]' -s m -l max -a "(seq 1 10)" -d "Specify maximum number of splits"
@ -21,11 +21,11 @@ complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "join0"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "trim"
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s l -l left -d "Trim only leading chars"
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s r -l right -d "Trim only trailing chars"
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s c -l chars -d "Specify the chars to trim (default: whitespace)"
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] trim" -s c -l chars -d "Specify the chars to trim (default: whitespace)" -x
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "escape"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "unescape"
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] escape; or contains -- (commandline -opc)[2] unescape" -s n -l no-quoted -d "Escape with \\ instead of quotes"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] escape; or contains -- (commandline -opc)[2] unescape" -l style -d "Specify escaping style" -a "
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] escape; or contains -- (commandline -opc)[2] unescape" -l style -d "Specify escaping style" -xa "
(printf '%s\t%s\n' script 'For use in scripts' \
var 'For use as a variable name' \
regex 'For string match -r, string replace -r' \
@ -42,6 +42,6 @@ complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains --
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s r -l regex -d "Use regex instead of globs"
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "repeat"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] repeat" -s n -l count -a "(seq 1 10)" -d "Repetition count"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] repeat" -s m -l max -a "(seq 1 10)" -d "Maximum number of printed chars"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] repeat" -s n -l count -xa "(seq 1 10)" -d "Repetition count"
complete -x -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] repeat" -s m -l max -xa "(seq 1 10)" -d "Maximum number of printed chars"
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] repeat" -s N -l no-newline -d "Remove newline"