Merge pull request #5356 from oxiedi/update-shell-completions

Update shell completions
This commit is contained in:
TW 2020-09-27 21:34:27 +02:00 committed by GitHub
commit 2f70bfb868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 43 deletions

View File

@ -63,7 +63,7 @@ _borg()
return 0
;;
'--recompress')
local recompress_when="if-different always"
local recompress_when="if-different always never"
COMPREPLY=( $(compgen -W "${recompress_when}" -- ${cur}) )
return 0
;;
@ -75,7 +75,7 @@ _borg()
local opts="-e --encryption --append-only --storage-quota --make-parent-dirs ${common_opts}"
;;
*' create '*)
local opts="-n --dry-run -s --stats --list --filter --json --no-cache-sync --stdin-name -e --exclude --exclude-from --pattern --patterns-from --exclude-caches --exclude-if-present --keep-exclude-tags --exclude-nodump -x --one-file-system --numeric-owner --noatime --noctime --nobirthtime --nobsdflags --noflags --files-cache --read-special --comment --timestamp -c --checkpoint-interval --chunker-params -C --compression ${common_opts}"
local opts="-n --dry-run -s --stats --list --filter --json --no-cache-sync --stdin-name --content-from-command -e --exclude --exclude-from --pattern --patterns-from --exclude-caches --exclude-if-present --keep-exclude-tags --exclude-nodump -x --one-file-system --numeric-owner --noatime --noctime --nobirthtime --nobsdflags --noflags --files-cache --read-special --comment --timestamp -c --checkpoint-interval --chunker-params -C --compression ${common_opts}"
;;
*' extract '*)
local opts="--list -n --dry-run --numeric-owner --nobsdflags --noflags --stdout --sparse -e --exclude --exclude-from --pattern --patterns-from --strip-components ${common_opts}"

View File

@ -100,6 +100,7 @@ complete -c borg -f -l 'filter' -d 'Only items with given ST
complete -c borg -f -l 'json' -d 'Print verbose stats as json' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'no-cache-sync' -d 'Do not synchronize the cache' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'stdin-name' -d 'Use NAME in archive for stdin data' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'content-from-command' -d 'Interpret PATH as command and store its stdout' -n "__fish_seen_subcommand_from create"
# Exclusion options
complete -c borg -s e -l 'exclude' -d 'Exclude paths matching PATTERN' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'exclude-from' -d 'Read exclude patterns from EXCLUDEFILE' -n "__fish_seen_subcommand_from create"
@ -292,7 +293,7 @@ complete -c borg -f -l 'comment' -d 'Add COMMENT to the archi
complete -c borg -f -l 'timestamp' -d 'Set creation TIME (yyyy-mm-ddThh:mm:ss)' -n "__fish_seen_subcommand_from recreate"
complete -c borg -l 'timestamp' -d 'Set creation time using reference FILE' -n "__fish_seen_subcommand_from recreate"
complete -c borg -f -s C -l 'compression' -d 'Select compression ALGORITHM,LEVEL [lz4]' -a "$compression_methods" -n "__fish_seen_subcommand_from recreate"
set -l recompress_when "if-different always"
set -l recompress_when "if-different always never"
complete -c borg -f -l 'recompress' -d 'Recompress chunks CONDITION' -a "$recompress_when" -n "__fish_seen_subcommand_from recreate"
complete -c borg -f -l 'chunker-params' -d 'Chunker PARAMETERS [19,23,21,4095]' -n "__fish_seen_subcommand_from recreate"

View File

@ -1,6 +1,6 @@
#compdef borg borgfs -P -value-,BORG_*,-default-
# Zsh completion for Borg Backup 1.2.0a8 (2020-04-21).
# Zsh completion for Borg Backup 1.2.0a9 (2020-09-27).
#
# Recommended _borg specific settings:
#
@ -127,17 +127,25 @@ _borg-config() {
(( $+functions[_borg-create] )) ||
_borg-create() {
local -a common_options common_create_options
local -a common_options common_create_options state line
local curcontext="$curcontext" state_descr
declare -A opt_args
local -i ret=1
__borg_setup_common_options
__borg_setup_common_create_options
_arguments -s -w -S : \
local lastspec='*:PATH:_files'
(( $words[(I)--content-from-command] )) &&
lastspec='*:::PATH:->command'
_arguments -C -s -w -S : \
'*'{-e,--exclude}'=[exclude paths matching PATTERN]: : _borg_style_selector_or_archive_files -f -e "$line[1]" fm "${(@)line[2,-1]}"' \
'*--pattern=[experimental: include/exclude paths matching PATTERN]: : _borg_style_selector_or_archive_files -p -f -e "$line[1]" sh "${(@)line[2,-1]}"' \
$common_create_options \
'(-s --stats)--json[Output stats as JSON. Implies --stats.]' \
'--no-cache-sync[experimental: do not synchronize the cache. Implies not using the files cache.]' \
'--stdin-name=[use NAME in archive for stdin data (default: "stdin")]:NAME' \
'--content-from-command[interpret PATH as command and store its stdout]' \
'--exclude-nodump[exclude files flagged NODUMP]' \
'(-x --one-file-system)'{-x,--one-file-system}'[stay in the same file system]' \
'--numeric-owner[only store numeric user and group identifiers]' \
@ -151,7 +159,19 @@ _borg-create() {
'--read-special[open and read block and char device files as well as FIFOs as if they were regular files]' \
$common_options \
':ARCHIVE: _borg_repository_or_archive -a -p' \
'*:PATH:_files'
$lastspec && ret=0
case $state in
(command)
if (( CURRENT <= 1 )); then
_command_names -e && ret=0
else
_normal && ret=0
fi
;;
esac
return ret
}
(( $+functions[_borg-debug] )) ||
@ -273,7 +293,7 @@ _borg-delete() {
_arguments -s -w -S : \
$common_dry_run_stats_options \
'--cache-only[delete only the local cache for the given repository]' \
'*--force[force deletion of corrupted archives, use --force --force in case --force does not work.]' \
'*--force[force deletion of corrupted archives, use "--force --force" in case "--force" does not work]' \
'--keep-security-info[keep the local security info when deleting a repository]' \
'--save-space[work slower, but using less space]' \
$common_archive_filters_options \
@ -499,7 +519,7 @@ _borg-prune() {
_arguments -s -w -S : \
$common_dry_run_stats_options \
'--force[force pruning of corrupted archives]' \
'*--force[force pruning of corrupted archives, use "--force --force" in case "--force" does not work]' \
'--list[output verbose list of archives it keeps/prunes]' \
'--keep-within[keep all archives within this time interval]: : _borg_guard_unsigned_number "INTERVAL"' \
'(--keep-last --keep-secondly)'{--keep-last,--keep-secondly}'[number of secondly archives to keep]: : _borg_guard_unsigned_number "N"' \
@ -521,10 +541,18 @@ _borg-recreate() {
__borg_setup_common_options
__borg_setup_common_create_options
local -a mods=(
'if-different:recompress if current compression is with a different compression algorithm (the level is not considered)'
'always:recompress even if current compression is with the same compression algorithm (use this to change the compression level)'
'never:do not recompress (use this option to explicitly prevent recompression)'
)
mods=( ${(q)mods//\\/\\\\} )
mods=( ${mods//:/\\:} )
_arguments -s -w -S : \
$common_create_options \
'--target[create a new archive with the name ARCHIVE]:ARCHIVE: _borg_placeholder_or_archive "${line[1]%%\:\:*}"' \
'--recompress[recompress data chunks according to --compression]:params:((if-different always never\:\(default\)))' \
'--target=[create a new archive with the name ARCHIVE]:ARCHIVE: _borg_placeholder_or_archive "${line[1]%%\:\:*}"' \
'--recompress=[recompress data chunks according to "MODE" and "--compression"]:MODE:'"(($mods))" \
$common_options \
':REPOSITORY_OR_ARCHIVE: _borg_repository_or_archive' \
'*: : _borg_style_selector_or_archive_files -e "$line[1]" pp'
@ -619,7 +647,7 @@ __borg_setup_common_options() {
'--bypass-lock[bypass locking mechanism]'
'(- :)--show-version[show/log the borg version]'
'--show-rc[show/log the return code (rc)]'
'--umask=[set umask to M (local and remote, default: 0077)]:M'
'--umask=[set umask to M (local only, default: 0077)]:M'
'--remote-path=[set remote path to executable (default: "borg")]: :_cmdstring'
'--remote-ratelimit=[set remote network upload rate limit in kiByte/s (default: 0=unlimited)]: : _borg_guard_unsigned_number "RATE"'
'--consider-part-files[treat part files like normal files (e.g. to list/extract them)]'
@ -756,6 +784,9 @@ _borg_parameters() {
(WORKAROUNDS)
_wanted workarounds expl 'workaround' _sequence compadd - basesyncfile && ret=0
;;
(KEYS_DIR)
_directories && ret=0
;;
(*)
_default && ret=0
;;
@ -1102,8 +1133,8 @@ _borg_format_keys() {
local -a keys=( NEWLINE NL NUL SPACE TAB CR LF )
local -a repository_keys=( archive name barchive comment bcomment id start time end hostname username )
local -a archive_keys=( type mode uid gid user group path bpath source linktarget flags size csize dsize dcsize
num_chunks unique_chunks mtime ctime atime isomtime isoctime isoatime md5 sha1 sha224 sha256 sha384 sha512
xxh64 archiveid archivename extra health )
num_chunks unique_chunks mtime ctime atime isomtime isoctime isoatime blake2b blake2s md5 sha1 sha224 sha256 sha384
sha3_224 sha3_256 sha3_384 sha3_512 sha512 shake_128 shake_256 archiveid archivename extra health )
local akeys rkeys
akeys='archive-keys:archive keys:compadd -a archive_keys'