scripts/completion.pl: improve zsh completion

- 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
This commit is contained in:
Leah Neukirchen 2022-01-31 18:28:01 +01:00 committed by Daniel Stenberg
parent 9cc75eb7dd
commit 90c4581389
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -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;