From a3e20a4d38076a19dca3b13c32dbcb2b4f2dda61 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 19 Sep 2020 11:39:51 +0200 Subject: [PATCH] Don't use abbreviated long options "function --argument" is not a thing, it's "--argument-names". This only accidentally works because our getopt is awful and allows abbreviated long options. Similarly, one argparse test used "--d" instead of "-d" or "--def". --- share/completions/j.fish | 2 +- share/completions/phpunit.fish | 2 +- share/completions/ssh.fish | 2 +- share/completions/valgrind.fish | 2 +- share/completions/wvdial.fish | 2 +- share/functions/__fish_append.fish | 2 +- share/functions/__fish_complete_convert_options.fish | 2 +- share/functions/__fish_complete_directories.fish | 2 +- share/functions/__fish_complete_list.fish | 2 +- share/functions/__fish_complete_ssh.fish | 2 +- share/functions/__fish_is_token_n.fish | 2 +- share/functions/__fish_print_help.fish | 2 +- tests/checks/argparse.fish | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/share/completions/j.fish b/share/completions/j.fish index be799ee48..53ec3c62b 100644 --- a/share/completions/j.fish +++ b/share/completions/j.fish @@ -1,4 +1,4 @@ -function __history_completions --argument limit +function __history_completions --argument-names limit if string match -q "" -- "$limit" set limit 25 end diff --git a/share/completions/phpunit.fish b/share/completions/phpunit.fish index 56c51c86d..8cd039fd3 100644 --- a/share/completions/phpunit.fish +++ b/share/completions/phpunit.fish @@ -9,7 +9,7 @@ function __fish_phpunit_list_groups end # Lists PHPUnit objects corresponding to the given option -function __fish_phpunit_list --argument option +function __fish_phpunit_list --argument-names option # Use the same PHPUnit binary as in the command being completed set -l phpunit (commandline -opc)[1] test -x $phpunit diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index 7aa624b94..38b848b5d 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -54,7 +54,7 @@ complete -c ssh -s D -d "Dynamic port forwarding" complete -c ssh -s c -d "Encryption cipher" -xa "(ssh -Q cipher)" # Also retrieve `user@host` entries from history -function __ssh_history_completions --argument limit +function __ssh_history_completions --argument-names limit if string match -q "" set limit 100 end diff --git a/share/completions/valgrind.fish b/share/completions/valgrind.fish index 9ab7fed5d..bf9925f3b 100644 --- a/share/completions/valgrind.fish +++ b/share/completions/valgrind.fish @@ -17,7 +17,7 @@ complete -xc valgrind -l $skin -d Skin -a " massif\tHeap\ profiler " -function __fish_valgrind_skin --argument tool -V skin +function __fish_valgrind_skin --argument-names tool -V skin set -l cmd (commandline -cpo) # Quote $cmd so the tokens are separated with a space if string match -qr -- "--$skin(=| )$tool" "$cmd" diff --git a/share/completions/wvdial.fish b/share/completions/wvdial.fish index 65c812ea5..c339c10d1 100644 --- a/share/completions/wvdial.fish +++ b/share/completions/wvdial.fish @@ -1,4 +1,4 @@ -function __fish_complete_wvdial_peers --description 'Complete wvdial peers' --argument cfgfiles +function __fish_complete_wvdial_peers --description 'Complete wvdial peers' --argument-names cfgfiles set -q cfgfiles[1] or set -l cfgfiles /etc/wvdial.conf ~/.wvdialrc diff --git a/share/functions/__fish_append.fish b/share/functions/__fish_append.fish index 1c1a9deeb..07e447d94 100644 --- a/share/functions/__fish_append.fish +++ b/share/functions/__fish_append.fish @@ -1,4 +1,4 @@ -function __fish_append -d "Internal completion function for appending string to the commandline" --argument sep +function __fish_append -d "Internal completion function for appending string to the commandline" --argument-names sep set -e argv[1] set -l str (commandline -tc | string replace -rf "(.*$sep)[^$sep]*" '$1' | string replace -r -- '--.*=' '') printf "%s\n" "$str"$argv diff --git a/share/functions/__fish_complete_convert_options.fish b/share/functions/__fish_complete_convert_options.fish index b32a55120..686149b09 100644 --- a/share/functions/__fish_complete_convert_options.fish +++ b/share/functions/__fish_complete_convert_options.fish @@ -1,4 +1,4 @@ -function __fish_complete_convert_options --description 'Complete Convert options' --argument what +function __fish_complete_convert_options --description 'Complete Convert options' --argument-names what switch $what case format Format convert -list Format | sed '1,/----/d; /^$/,$d; /^$/d; s/^\s*\([a-zA-Z0-9-]\+\)\**\s*\S\+\s\+\\(\S\+\)\s\+\(.\+\S\)\s*$/\1\t\2 \3/' diff --git a/share/functions/__fish_complete_directories.fish b/share/functions/__fish_complete_directories.fish index cebdbeef6..a4db0ec22 100644 --- a/share/functions/__fish_complete_directories.fish +++ b/share/functions/__fish_complete_directories.fish @@ -3,7 +3,7 @@ # with description $argv[2] if defined, otherwise use 'Directory'. # If no arguments are provided, attempts to complete current commandline token. # -function __fish_complete_directories -d "Complete directory prefixes" --argument comp desc +function __fish_complete_directories -d "Complete directory prefixes" --argument-names comp desc if not set -q desc[1] set desc Directory end diff --git a/share/functions/__fish_complete_list.fish b/share/functions/__fish_complete_list.fish index bfe3ecf91..a832cbf63 100644 --- a/share/functions/__fish_complete_list.fish +++ b/share/functions/__fish_complete_list.fish @@ -1,4 +1,4 @@ -function __fish_complete_list --argument div cmd prefix iprefix +function __fish_complete_list --argument-names div cmd prefix iprefix if not set -q cmd[1] echo "Usage: __fish_complete_list diff --git a/share/functions/__fish_complete_ssh.fish b/share/functions/__fish_complete_ssh.fish index f92ac009a..016a10e53 100644 --- a/share/functions/__fish_complete_ssh.fish +++ b/share/functions/__fish_complete_ssh.fish @@ -1,4 +1,4 @@ -function __fish_complete_ssh -d "common completions for ssh commands" --argument command +function __fish_complete_ssh -d "common completions for ssh commands" --argument-names command complete -c $command -s 1 -d "Protocol version 1 only" complete -c $command -s 2 -d "Protocol version 2 only" complete -c $command -s 4 -d "IPv4 addresses only" diff --git a/share/functions/__fish_is_token_n.fish b/share/functions/__fish_is_token_n.fish index eccd9ace2..c0c698644 100644 --- a/share/functions/__fish_is_token_n.fish +++ b/share/functions/__fish_is_token_n.fish @@ -1,4 +1,4 @@ -function __fish_is_token_n --description 'Test if current token is on Nth place' --argument n +function __fish_is_token_n --description 'Test if current token is on Nth place' --argument-names n # Add a fake element to increment without calling math set -l num (count (commandline -poc) additionalelement) test $n -eq $num diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index f7b893003..788e4314c 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -1,4 +1,4 @@ -function __fish_print_help --description "Print help message for the specified fish function or builtin" --argument item error_message +function __fish_print_help --description "Print help message for the specified fish function or builtin" --argument-names item error_message switch $item case . set item source diff --git a/tests/checks/argparse.fish b/tests/checks/argparse.fish index f08041d60..4538727b2 100644 --- a/tests/checks/argparse.fish +++ b/tests/checks/argparse.fish @@ -160,7 +160,7 @@ end # Required, optional, and multiple flags begin - argparse h/help 'a/abc=' 'd/def=?' 'g/ghk=+' -- help --help me --ghk=g1 --abc=ABC --ghk g2 --d -g g3 + argparse h/help 'a/abc=' 'd/def=?' 'g/ghk=+' -- help --help me --ghk=g1 --abc=ABC --ghk g2 -d -g g3 set -l # CHECK: _flag_a ABC # CHECK: _flag_abc ABC