Skip to content

Commit

Permalink
Merge pull request #1237 from yedayak/curl-data-
Browse files Browse the repository at this point in the history
Complete stdin "-" in file locations, add more options that allow it
  • Loading branch information
akinomyoga authored Aug 23, 2024
2 parents 07605cb + 62c0ecb commit 6f03827
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions completions/curl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ _comp_cmd_curl()
--sasl-authzid | --service-name | --socks5-gssapi-service | \
--speed-limit | --speed-time | --telnet-option | --tftp-blksize | \
--time-cond | --tls13-ciphers | --tlspassword | --tlsuser | \
--url | --user | --user-agent | --version | --write-out | \
-${noargopts}[CFmQreYytzuAVw])
--url | --user | --user-agent | --version | \
-${noargopts}[CFmQreYytzuAV])
return
;;
--cacert | --cert | --proxy-cacert | --proxy-cert | -${noargopts}E)
Expand All @@ -50,10 +50,11 @@ _comp_cmd_curl()
_comp_compgen_filedir crl
return
;;
--data | --data-ascii | --data-binary | --data-urlencode | --header | \
--proxy-header | -${noargopts}[dH])
--data | --data-ascii | --data-binary | --data-urlencode | --json | \
--header | --proxy-header | --write-out | -${noargopts}[dHw])
if [[ $cur == \@* ]]; then
_comp_compgen -c "${cur:1}" filedir
_comp_compgen -a -c "${cur:1}" -- -W '-'
if [[ ${#COMPREPLY[@]} -eq 1 && -d ${COMPREPLY[0]} ]]; then
COMPREPLY[0]+=/
compopt -o nospace
Expand Down
3 changes: 2 additions & 1 deletion test/t/test_curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def test_4(self, completion):

@pytest.mark.complete("curl --data @", cwd="shared/default/foo.d")
def test_data_atfile(self, completion):
assert completion == "foo"
assert "@foo" in completion
assert "@-" in completion

@pytest.mark.complete("curl --data @foo.", cwd="shared/default")
def test_data_atfile_dir(self, completion):
Expand Down

0 comments on commit 6f03827

Please sign in to comment.