update shell completions

This commit is contained in:
oxiedi 2020-12-24 16:06:00 +05:00
parent 5f2c3cf48a
commit 139807282d
3 changed files with 45 additions and 18 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 --keep-tag-files --exclude-nodump -x --one-file-system --numeric-owner --noatime --noctime --nobirthtime --nobsdflags --ignore-inode --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 --stdin-user --stdin-group --stdin-mode -e --exclude --exclude-from --pattern --patterns-from --exclude-caches --exclude-if-present --keep-exclude-tags --keep-tag-files --exclude-nodump -x --one-file-system --numeric-owner --noatime --noctime --nobirthtime --nobsdflags --ignore-inode --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 --stdout --sparse -e --exclude --exclude-from --pattern --patterns-from --strip-components ${common_opts}"

View File

@ -92,13 +92,17 @@ 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 'stdin-user' -d 'Set user USER in archive for stdin data [root]' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'stdin-group' -d 'Set group GROUP in archive for stdin data [root]' -n "__fish_seen_subcommand_from create"
complete -c borg -f -l 'stdin-mode' -d 'Set mode to M in archive for stdin data [0660]' -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"
@ -288,7 +292,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.1.14 (2020-09-27).
# Zsh completion for Borg Backup 1.1.15.
#
# Recommended _borg specific settings:
#
@ -136,6 +136,9 @@ _borg-create() {
'--no-cache-sync[experimental: do not synchronize the cache. Implies not using the files cache.]' \
'--no-files-cache[do not load/update the file metadata cache used to detect unchanged files]' \
'--stdin-name=[use NAME in archive for stdin data (default: "stdin")]:NAME' \
'--stdin-user=[set user USER in archive for stdin data (default: root)]:USER:_users' \
'--stdin-group=[set group GROUP in archive for stdin data (default: root)]:GROUP:_groups' \
'--stdin-mode=[set mode to M in archive for stdin data (default: 0660)]: : _borg_guard_numeric_mode "M"' \
'--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]' \
@ -270,7 +273,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]' \
'--save-space[work slower, but using less space]' \
$common_archive_filters_options \
$common_options \
@ -492,7 +495,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"' \
@ -514,10 +517,17 @@ _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//\\/\\\\}//:/\\:} )
_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'
@ -612,7 +622,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 and remote, default: 0077)]: : _borg_guard_numeric_mode "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)]'
@ -729,6 +739,9 @@ _borg_parameters() {
(HOST_ID)
_message -e 'unique ID' && ret=0
;;
(FILES_CACHE_SUFFIX)
_message -e 'suffix' && ret=0
;;
(FILES_CACHE_TTL)
_borg_guard_unsigned_number 'time to live (default: 20)' && ret=0
;;
@ -747,7 +760,10 @@ _borg_parameters() {
compadd "$expl[@]" YES NO && ret=0
;;
(WORKAROUNDS)
_wanted workarounds expl 'workaround' _sequence compadd - basesyncfile && ret=0
_wanted workarounds expl 'workaround' _sequence -n 1 compadd - basesyncfile && ret=0
;;
(KEYS_DIR)
_directories && ret=0
;;
(*)
_default && ret=0
@ -1478,7 +1494,7 @@ _borg_chunker_params() {
if compset -P '*,*,*,'; then
_message -e 'HASH_WINDOW_SIZE'
elif compset -P '*,*,'; then
_message -e 'HASH_MASK_BITS (statistical medium chunk size ~= 2^HASH_MASK_BITS B)'
_message -e 'HASH_MASK_BITS (target chunk size ~= 2^HASH_MASK_BITS B)'
elif compset -P '*,'; then
_message -e 'CHUNK_MAX_EXP (maximum chunk size = 2^CHUNK_MAX_EXP B)'
else
@ -1542,6 +1558,13 @@ _borg_guard_unsigned_number() {
_guard '[0-9]#' ${1:-number}
}
(( $+functions[_borg_guard_numeric_mode] )) ||
_borg_guard_numeric_mode() {
local -A opts
zparseopts -K -D -A opts M+: J+: V+: 1 2 o+: n F: x+: X+:
_guard '[0-7](#c0,4)' ${1:-mode}
}
_borg() {
local -a match mbegin mend line state
local curcontext="$curcontext" state_descr