]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
scripts/completion.pl: improve zsh completion
authorLeah Neukirchen <leah@vuxu.org>
Mon, 31 Jan 2022 17:28:01 +0000 (18:28 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 2 Feb 2022 12:17:05 +0000 (13:17 +0100)
- Detect all spellings of <file>, <file name> etc as well as <path>.
- Only complete directories for <dir>.
- Complete URLs for <URL>.
- Complete --request and --ftp-method.

Closes #8363

scripts/completion.pl

index 8bbf4838ab953eef866848098a447a722336852c..299f86055cbfb271477a022fbacb0b23dae70ad5 100755 (executable)
@@ -102,11 +102,20 @@ sub parse_main_opts {
             $option .= '}' if defined $short;
             $option .= '\'[' . trim($desc) . ']\'' if defined $desc;
 
-            $option .= ":'$arg'" if defined $arg;
-
-            $option .= ':_files'
-                if defined $arg and ($arg eq '<file>' || $arg eq '<filename>'
-                    || $arg eq '<dir>');
+            if (defined $arg) {
+                $option .= ":'$arg'";
+                if ($arg =~ /<file ?(name)?>|<path>/) {
+                    $option .= ':_files';
+                } elsif ($arg =~ /<dir>/) {
+                    $option .= ":'_path_files -/'";
+                } elsif ($arg =~ /<url>/i) {
+                    $option .= ':_urls';
+                } elsif ($long =~ /ftp/ && $arg =~ /<method>/) {
+                    $option .= ":'(multicwd nocwd singlecwd)'";
+                } elsif ($arg =~ /<method>/) {
+                    $option .= ":'(DELETE GET HEAD POST PUT)'";
+                }
+            }
         }
 
         push @list, $option;