Skip to content

Commit 7e7928d

Browse files
sbrazscop
authored andcommitted
fix(rsync): improve completion by using _parse_help
Also add tests for non-hardcoded options and add some options not shown in "rsync --help".
1 parent a7aabbc commit 7e7928d

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

completions/rsync

+9-26
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,15 @@ _rsync()
3737

3838
case $cur in
3939
-*)
40-
COMPREPLY=($(compgen -W '--verbose --quiet --no-motd --checksum
41-
--archive --recursive --relative --no-implied-dirs
42-
--backup --backup-dir= --suffix= --update --inplace --append
43-
--append-verify --dirs --old-dirs --links --copy-links
44-
--copy-unsafe-links --safe-links --copy-dirlinks
45-
--keep-dirlinks --hard-links --perms --executability --chmod=
46-
--acls --xattrs --owner --group --devices --copy-devices
47-
--specials --times --omit-dir-times --super --fake-super
48-
--sparse --dry-run --whole-file --no-whole-file
49-
--one-file-system --block-size= --rsh= --rsync-path=
50-
--existing --ignore-existing --remove-source-files --delete
51-
--delete-before --delete-during --delete-delay --delete-after
52-
--delete-excluded --ignore-errors --force --max-delete=
53-
--max-size= --min-size= --partial --partial-dir=
54-
--delay-updates --prune-empty-dirs --numeric-ids --timeout=
55-
--contimeout= --ignore-times --size-only --modify-window=
56-
--temp-dir= --fuzzy --compare-dest= --copy-dest= --link-dest=
57-
--compress --compress-level= --skip-compress= --cvs-exclude
58-
--filter= --exclude= --exclude-from= --include= --include-from=
59-
--files-from= --from0 --protect-args --address= --port=
60-
--sockopts= --blocking-io --no-blocking-io --stats
61-
--8-bit-output --human-readable --progress --itemize-changes
62-
--out-format= --log-file= --log-file-format= --password-file=
63-
--list-only --bwlimit= --write-batch= --only-write-batch=
64-
--read-batch= --protocol= --iconv= --ipv4 --ipv6 --version
65-
--help --daemon --config= --no-detach' -- "$cur"))
40+
COMPREPLY=($(
41+
# Account for the fact that older rsync versions (before cba00be6, meaning before v3.2.0)
42+
# contain the following unusual line in --help:
43+
# "(-h) --help show this help (-h is --help only if used alone)"
44+
compgen -W '$(
45+
"$1" --help 2>&1 | sed -e "s/^([^)]*)//" | _parse_help -)
46+
--daemon --old-d{,irs}
47+
--no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION' -- "$cur"
48+
))
6649
[[ ${COMPREPLY-} == *= ]] || compopt +o nospace
6750
;;
6851
*:*)

test/t/test_rsync.py

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ def test_2(self, completion):
1414
@pytest.mark.complete("rsync --rsh=")
1515
def test_3(self, completion):
1616
assert completion == "rsh ssh".split()
17+
18+
@pytest.mark.complete("rsync --", require_cmd=True)
19+
def test_4(self, completion):
20+
assert "--help" in completion

test/test-cmd-list.txt

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ rmdir
322322
rmmod
323323
rpm
324324
rpmbuild
325+
rsync
325326
rtcwake
326327
sbopkg
327328
screen

0 commit comments

Comments
 (0)