mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
string completions: add -e, -f, --no-empty, shorten -d's
I hope this is now complete. Also, shorten enough descriptions to make `string match --<TAB>` show a two column pager with 80 cols. We really should have shown more retraint in the design of `string`, not all of the flags required both a long and short option created.
This commit is contained in:
parent
7c8b444927
commit
1049bed5f8
2 changed files with 14 additions and 8 deletions
|
@ -12,29 +12,34 @@ 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"
|
||||
complete -f -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr split0\?\$ -- (commandline -opc)[2]' -s r -l right -d "Split right-to-left"
|
||||
complete -f -c string -n 'test (count (commandline -opc)) -ge 2; and string match -qr split0\?\$ -- (commandline -opc)[2]' -s n -l no-empty -d "Empty results excluded"
|
||||
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "join"
|
||||
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 characters"
|
||||
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 characters"
|
||||
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)) -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 "Escaped with \\ instead of quoted"
|
||||
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 "Escaping style" -a "
|
||||
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 "
|
||||
(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' \
|
||||
url 'For use as a URL')"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "match"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match" -s n -l index -d "Report index and length of the matches"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match" -s v -l invert -d "Report only non-matching input"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match" -s n -l index -d "Report index, length of match"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match" -s v -l invert -d "Report only non-matches"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match" -s e -l entire -d "Show entire matching lines"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -lt 2" -a "replace"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] replace" -s f -l filter -d "Report only actual replacements"
|
||||
# All replace options are also valid for match
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s a -l all -d "Report all matches per line/string"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s a -l all -d "Report every match"
|
||||
complete -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] match replace" -s i -l ignore-case -d "Case insensitive"
|
||||
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 char"
|
||||
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 -f -c string -n "test (count (commandline -opc)) -ge 2; and contains -- (commandline -opc)[2] repeat" -s N -l no-newline -d "Remove newline"
|
||||
|
|
|
@ -413,6 +413,7 @@ static wcstring construct_short_opts(options_t *opts) { //!OCLINT(high npath co
|
|||
|
||||
// Note that several long flags share the same short flag. That is okay. The caller is expected
|
||||
// to indicate that a max of one of the long flags sharing a short flag is valid.
|
||||
// Remember: adjust share/functions/string.fish when `string` options change
|
||||
static const struct woption long_options[] = {
|
||||
{L"all", no_argument, NULL, 'a'}, {L"chars", required_argument, NULL, 'c'},
|
||||
{L"count", required_argument, NULL, 'n'}, {L"entire", no_argument, NULL, 'e'},
|
||||
|
|
Loading…
Reference in a new issue