Skip to content

Commit

Permalink
curl: make @filename completion do the right thing with dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Oct 20, 2019
1 parent da99bc5 commit aa3652b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions completions/curl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ _curl()
if [[ $cur == \@* ]]; then
cur=${cur:1}
_filedir
if [[ ${#COMPREPLY[@]} -eq 1 && -d "${COMPREPLY[0]}" ]]; then
COMPREPLY[0]+=/
compopt -o nospace
fi
COMPREPLY=( "${COMPREPLY[@]/#/@}" )
fi
return
Expand Down
9 changes: 9 additions & 0 deletions test/t/test_curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ def test_3(self, completion):
@pytest.mark.complete("curl --o f")
def test_4(self, completion):
assert not completion

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

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

0 comments on commit aa3652b

Please sign in to comment.