Update shell completions

This commit is contained in:
oxiedi 2020-09-27 22:59:38 +05:00
parent b66cad427e
commit a887ed16c7
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

@ -93,40 +93,41 @@ complete -c borg -f -l 'storage-quota' -d 'Set storage QUOTA of the
complete -c borg -f -l 'make-parent-dirs' -d 'Create parent directories' -n "__fish_seen_subcommand_from init"
# borg create options
complete -c borg -f -s n -l 'dry-run' -d 'Do not change the repository' -n "__fish_seen_subcommand_from create"
complete -c borg -f -s s -l 'stats' -d 'Print verbose statistics' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'list' -d 'Print verbose list of items' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'filter' -d 'Only items with given STATUSCHARS' -n "__fish_seen_subcommand_from create"
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 -s n -l 'dry-run' -d 'Do not change the repository' -n "__fish_seen_subcommand_from create"
complete -c borg -f -s s -l 'stats' -d 'Print verbose statistics' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'list' -d 'Print verbose list of items' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'filter' -d 'Only items with given STATUSCHARS' -n "__fish_seen_subcommand_from create"
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"
complete -c borg -f -l 'pattern' -d 'Include/exclude paths matching PATTERN' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'patterns-from' -d 'Include/exclude paths from PATTERNFILE' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'exclude-caches' -d 'Exclude directories tagged as cache' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'exclude-if-present' -d 'Exclude directories that contain FILENAME' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'keep-exclude-tags' -d 'Keep tag files of excluded directories' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'keep-tag-files' -d 'Keep tag files of excluded directories' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'exclude-nodump' -d 'Exclude files flagged NODUMP' -n "__fish_seen_subcommand_from create"
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"
complete -c borg -f -l 'pattern' -d 'Include/exclude paths matching PATTERN' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'patterns-from' -d 'Include/exclude paths from PATTERNFILE' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'exclude-caches' -d 'Exclude directories tagged as cache' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'exclude-if-present' -d 'Exclude directories that contain FILENAME' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'keep-exclude-tags' -d 'Keep tag files of excluded directories' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'keep-tag-files' -d 'Keep tag files of excluded directories' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'exclude-nodump' -d 'Exclude files flagged NODUMP' -n "__fish_seen_subcommand_from create"
# Filesytem options
complete -c borg -f -s x -l 'one-file-system' -d 'Stay in the same file system' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'numeric-owner' -d 'Only store numeric user:group identifiers' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'noatime' -d 'Do not store atime' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'noctime' -d 'Do not store ctime' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'nobirthtime' -d 'Do not store creation date' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'nobsdflags' -d 'Do not store bsdflags' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'noflags' -d 'Do not store flags' -n "__fish_seen_subcommand_from create"
complete -c borg -f -s x -l 'one-file-system' -d 'Stay in the same file system' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'numeric-owner' -d 'Only store numeric user:group identifiers' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'noatime' -d 'Do not store atime' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'noctime' -d 'Do not store ctime' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'nobirthtime' -d 'Do not store creation date' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'nobsdflags' -d 'Do not store bsdflags' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'noflags' -d 'Do not store flags' -n "__fish_seen_subcommand_from create"
set -l files_cache_mode "ctime,size,inode mtime,size,inode ctime,size mtime,size rechunk,ctime rechunk,mtime disabled"
complete -c borg -f -l 'files-cache' -d 'Operate files cache in MODE' -a "$files_cache_mode" -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'read-special' -d 'Open device files like regular files' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'read-special' -d 'Open device files like regular files' -n "__fish_seen_subcommand_from create"
# Archive options
complete -c borg -f -l 'comment' -d 'Add COMMENT to the archive' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'timestamp' -d 'Set creation TIME (yyyy-mm-ddThh:mm:ss)' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'timestamp' -d 'Set creation time by reference FILE' -n "__fish_seen_subcommand_from create"
complete -c borg -f -s c -l 'checkpoint-interval' -d 'Write checkpoint every N seconds [1800]' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'chunker-params' -d 'Chunker PARAMETERS [19,23,21,4095]' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'comment' -d 'Add COMMENT to the archive' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'timestamp' -d 'Set creation TIME (yyyy-mm-ddThh:mm:ss)' -n "__fish_seen_subcommand_from create"
complete -c borg -l 'timestamp' -d 'Set creation time by reference FILE' -n "__fish_seen_subcommand_from create"
complete -c borg -f -s c -l 'checkpoint-interval' -d 'Write checkpoint every N seconds [1800]' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'chunker-params' -d 'Chunker PARAMETERS [19,23,21,4095]' -n "__fish_seen_subcommand_from create"
set -l compression_methods "none auto lz4 zstd,1 zstd,2 zstd,3 zstd,4 zstd,5 zstd,6 zstd,7 zstd,8 zstd,9 zstd,10 zstd,11 zstd,12 zstd,13 zstd,14 zstd,15 zstd,16 zstd,17 zstd,18 zstd,19 zstd,20 zstd,21 zstd,22 zlib,1 zlib,2 zlib,3 zlib,4 zlib,5 zlib,6 zlib,7 zlib,8 zlib,9 lzma,0 lzma,1 lzma,2 lzma,3 lzma,4 lzma,5 lzma,6 lzma,7 lzma,8 lzma,9"
complete -c borg -f -s C -l 'compression' -d 'Select compression ALGORITHM,LEVEL [lz4]' -a "$compression_methods" -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'