summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authoroxiedi <oxiedi@yandex.ru>2020-07-22 01:39:09 +0500
committeroxiedi <oxiedi@yandex.ru>2020-07-24 22:52:50 +0500
commit2b869256a2410f137ab9c9ef9de9e704d1018652 (patch)
treebd4718bce7b237c790b4fdee12e67015eea32bc9 /scripts
parent303c11f245e0a23e522a53aaad8cbeaaa2074551 (diff)
Rewrite Zsh completion.
The new completion provides: - completion for almost all optional and positional arguments; - completion for Borg environment variables (parameters).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/shell_completions/zsh/_borg2009
1 files changed, 1585 insertions, 424 deletions
diff --git a/scripts/shell_completions/zsh/_borg b/scripts/shell_completions/zsh/_borg
index fc9035a4a..a893da7bb 100644
--- a/scripts/shell_completions/zsh/_borg
+++ b/scripts/shell_completions/zsh/_borg
@@ -1,448 +1,1609 @@
-#compdef borg
+#compdef borg borgfs -P -value-,BORG_*,-default-
-# -------
+# Zsh completion for Borg Backup 1.2.0a8 (2020-04-21).
#
-# To Install:
+# Recommended _borg specific settings:
#
-# Copy this file to /usr/[local]/share/zsh/site-functions/
+# zstyle -e ':completion:*:*:borg-*:argument-rest:*' tag-order \
+# '[[ $words[CURRENT] == -* ]] && reply=( "!archives archive-files" "-" )'
+# zstyle ':completion:*:*:(borg|-value-,BORG_)*' sort false
+# zstyle ':completion:*:*:borg-config:argument-2:keys' list-grouped false
+# zstyle ':completion:*:*:borg-*:*' gain-privileges true
+# zstyle ':completion:*' fake-parameters 'BORG_REPO:scalar'
#
-# -------
-# borgbackup ZSH completion
-# Kevin Gravier 2017 <kevin@mrkmg.com>
+# Custom styles:
#
-# The MIT License (MIT)
+# archive-description-format
+# Default: `{archive:<36} {time} [{id}]`.
+# archive-sort
+# In which order archive names should be listed.
+# Possible values are: `inverse`, `timestamp`, `name`, `id`.
+# file-description-format
+# Default: `{mode} {user:6} {group:6} {size:8d} {mtime} {path}{extra}`.
+# path-style-selector
+# Style selector used to select a path (when Borg would use either `pp` or `pf`).
+# Default: `fm`.
+# repository-suffix
+# This boolean style controls whether to add the `::` suffix to a repository.
+# Default: `true`.
-# Copyright (c) 2017 Kevin
+(( $+functions[_borg_commands] )) ||
+_borg_commands() {
+ local -a commands_=(
+ 'benchmark:benchmark command'
+ 'break-lock:break the repository lock'
+ 'check:check repository consistency'
+ 'compact:compact segment files in the repository'
+ 'config:get, set, and delete values in a repository or cache config file'
+ 'create:create new archive'
+ 'debug:debugging command (not intended for normal use)'
+ 'delete:delete an existing repository or archives'
+ 'diff:diff contents of two archives'
+ 'export-tar:export archive contents as a tarball'
+ 'extract:extract archive contents'
+ 'help:extra help'
+ 'info:show repository or archive information'
+ 'init:initialize an empty repository'
+ 'key:manage repository key'
+ 'list:list archive or repository contents'
+ 'mount:mount archive or an entire repository as a FUSE filesystem'
+ 'prune:prune repository archives according to specified rules'
+ 'recreate:re-create archives'
+ 'rename:rename an existing archive'
+ 'serve:start in server mode'
+ 'umount:un-mount the FUSE filesystem'
+ 'upgrade:upgrade a repository from a previous version'
+ 'with-lock:run a user specified command with the repository lock held'
+ )
+ _describe -t commands 'borg commands' commands_
+}
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
+(( $+functions[_borg-benchmark] )) ||
+_borg-benchmark() {
+ local -a common_options
+ __borg_setup_common_options
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
+ _arguments -s -w -S : \
+ $common_options \
+ ':type:(crud)' \
+ ': :_borg_repository' \
+ ':PATH:_files'
+}
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
+(( $+functions[_borg-break-lock] )) ||
+_borg-break-lock() {
+ local -a common_options
+ __borg_setup_common_options
+ _arguments -s -w -S : \
+ $common_options \
+ ':: :_borg_repository'
+}
+(( $+functions[_borg-check] )) ||
+_borg-check() {
+ local -a common_options common_archive_filters_options
+ __borg_setup_common_options
+ __borg_setup_common_archive_filters_options
-_borg() {
- typeset -A opt_args
- local -a borg_possible_commands borg_possible_key_commands commands keyCommands borg_common_options
- local command keyCommand item subItem
-
- borg_common_options=({-h,--help}'[show this help message and exit]'
- --critical'[work on log level CRITICAL]'
- --error'[work on log level ERROR]'
- --warning'[work on log level WARNING (default)]'
- {--info,-v,--verbose}'[work on log level INFO]'
- --debug'[work on log level DEBUG]'
- --default-topic'[enable TOPIC debugging (can be specified multiple times).]:TOPIC'
- {-p,--progress}'[show progress information]'
- --log-json'[Output one JSON object per log line instead of formatted text.]'
- --lock-wait'[wait at most SECONDS for acquiring a repository/cache lock (default: 1).]:SECONDS'
- --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)]:umask'
- --remote-path'[set remote path to executable (default: "borg")]:_files'
- --remote-ratelimit'[set remote network upload rate limit in kiByte/s (default: 0=unlimited)]:RATE'
- --consider-part-files'[treat part files like normal files (e.g. to list/extract them)]'
- --debug-profile'[write execution profile in Borg format into FILE.]:_files'
- --rsh'[use COMMAND instead of ssh]:COMMAND')
-
- borg_possible_commands=(init create extract check rename list diff delete prune compact info mount umount key upgrade recreate export-tar serve config with-lock break-lock benchmark help)
- borg_possible_key_commands=(change-passphrase import export)
- command=""
- keyCommand=""
-
- for item in $words; do
- (( ${borg_possible_commands[(I)$item]} )) && command=$item
- (( ${borg_possible_key_commands[(I)$item]} )) && keyCommand=$item
- done
+ _arguments -s -w -S : \
+ '--repository-only[only perform repository checks]' \
+ '--archives-only[only perform archives checks]' \
+ '(--repository-only)--verify-data[perform cryptographic archive data integrity verification]' \
+ '--repair[attempt to repair any inconsistencies found]' \
+ '--save-space[work slower, but using less space]' \
+ '--max-duration=[partial repo check for max. SECONDS]: : _borg_guard_unsigned_number "SECONDS"' \
+ $common_archive_filters_options \
+ $common_options \
+ '::REPOSITORY_OR_ARCHIVE: _borg_repository_or_archive'
+}
+
+(( $+functions[_borg-compact] )) ||
+_borg-compact() {
+ local -a common_options
+ __borg_setup_common_options
+
+ _arguments -s -w -S : \
+ $common_options \
+ '--cleanup-commits[cleanup commit-only 17-byte segment files]' \
+ '--threshold=[set minimum threshold for saved space in PERCENT (default: 10)]: : _borg_guard_unsigned_number "PERCENT (default\: 10)"' \
+ ':: :_borg_repository'
+}
+
+(( $+functions[_borg-config] )) ||
+_borg-config() {
+ local -a common_options
+ __borg_setup_common_options
+
+ _arguments -s -w -S : \
+ '(-c --cache)'{-c,--cache}'[get and set values from the repo cache]' \
+ '(-d --delete)'{-d,--delete}'[delete the key from the config]' \
+ '(-l --list)'{-l,--list}'[list the configuration of the repo]' \
+ $common_options \
+ ': :_borg_repository' \
+ ': : _borg_config $line[1]' \
+ '::VALUE'
+}
+
+(( $+functions[_borg-create] )) ||
+_borg-create() {
+ local -a common_options common_create_options
+ __borg_setup_common_options
+ __borg_setup_common_create_options
+
+ _arguments -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' \
+ '--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]' \
+ '--noatime[do not store atime into archive]' \
+ '--atime[do store atime into archive]' \
+ '--noctime[do not store ctime into archive]' \
+ '--nobirthtime[do not store birthtime (creation date) into archive]' \
+ '--nobsdflags[deprecated, use --noflags instead]' \
+ '--noflags[do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive]' \
+ '--files-cache=[operate files cache in MODE. default: ctime,size,inode]:MODE:(ctime,size,inode mtime,size,inode ctime,size mtime,size rechunk,ctime rechunk,mtime disabled)' \
+ '--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'
+}
+
+(( $+functions[_borg-debug] )) ||
+_borg-debug() {
+ local -a state line common_options
+ local curcontext="$curcontext" state_descr
+ declare -A opt_args
+ local -i ret=1
+ __borg_setup_common_options
- case $command in
- (init)
- _arguments \
- '2:repo:_files'\
- {-e,--encryption}'[select encryption key mode]:mode:(none keyfile keyfile-blake2 repokey repokey-blake2 authenticated authenticated-blake2)'\
- --append-only'[only allow appending to repository segment files]'\
- --storage-quota'[Override storage quota of the repository]:QUOTA'\
- --make-parent-dirs'[create parent directories]'\
- $borg_common_options
- ;;
- (create)
- _arguments \
- '2:archives:__borg_archive'\
- '3:path:_files'\
- {-n,--dry-run}'[do not create a backup archive]'\
- {-s,--stats}'[print statistics for the created archive]'\
- --list'[output verbose list of items (files, dirs, ...)]'\
- --filter'[only display items with the given status characters]:STATUSCHARS'\
- --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]:NAME'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- --exclude-caches'[exclude directories that contain a CACHEDIR.TAG file ]'\
- --exclude-if-present'[exclude directories that are tagged by containing a filesystem object with the given NAME]:NAME'\
- --keep-exclude-tags'[if tag objects are specified with --exclude-if-present, don’t omit the tag objects themselves]'\
- {-x,--one-file-system}'[stay in the same file system ]'\
- --numeric-owner'[only store numeric user and group identifiers]'\
- --noatime'[do not store atime into archive]'\
- --nobirthtime'[do not store birthtime (creation date) into archive]'\
- --nobsdflags'[do not read and store bsdflags (e.g. NODUMP, IMMUTABLE) into archive]'\
- --noflags'[do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive]'\
- --files-cache'[operate files cache in MODE. default: ctime,size,inode]:mode:(ctime,size,inode mtime,size,inode ctime,size mtime,size rechunk,ctime rechunk,mtime disabled)'\
- --read-special'[open and read block and char device files as well as FIFOs as if they were regular files.]'\
- --comment'[add a comment text to the archive]:COMMENT'\
- --timestamp'[manually specify the archive creation date/time]:TIMESTAMP'\
- --timestamp'[manually specify the archive creation date/time by a reference file/directory]:_files'\
- {-c,--checkpoint-interval}'[write checkpoint every SECONDS seconds]:SECONDS'\
- --chunker-params'[specify the chunker parameters]:PARAMS'\
- {-C,--compression}'[select compression algorithm]:COMPRESSION'\
- $borg_common_options
- ;;
- (extract)
- _arguments \
- '2:archives:__borg_archive'\
- '3:path:_files'\
- --list'[output verbose list of items (files, dirs, ...)]'\
- {-n,--dry-run}'[do not actually change any files]'\
- --numeric-owner'[only obey numeric user and group identifiers]'\
- --nobsdflags'[do not extract/set bsdflags (e.g. NODUMP, IMMUTABLE)]'\
- --noflags'[do not extract/set flags (e.g. NODUMP, IMMUTABLE)]'\
- --stdout'[write all extracted data to stdout]'\
- --sparse'[create holes in output sparse file from all-zero chunks]'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- --strip-components'[Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.]:NUMBER'\
- $borg_common_options
- ;;
- (check)
- _arguments \
- '2:archives:__borg_archive'\
- --repository-only'[only perform repository checks]'\
- --archives-only'[only perform archives checks]'\
- --verify-data'[perform cryptographic archive data integrity verification]'\
- --repair'[attempt to repair any inconsistencies found]'\
- --save-space'[work slower, but using less space]'\
- --max-duration'[partial repo check for max. SECONDS]:SECONDS'\
- {-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
- {-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
- --sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
- --first'[consider first N archives after other filters were applied]:N'\
- --last'[consider last N archives after other filters were applied]:N'\
- $borg_common_options
- ;;
- (rename)
- _arguments \
- '2:archives:__borg_archive'\
- '3:name:NAME'\
- $borg_common_options
- ;;
- (list)
- _arguments \
- '2:archives:__borg_archive'\
- '*:path:_files'\
- --short'[only print file/directory names, nothing else]'\
- --format'[specify format for file listing]:FORMAT'\
- --json'[Only valid for listing repository contents. Format output as JSON.]'\
- --json-lines'[Only valid for listing archive contents. Format output as JSON Lines. ]'\
- {-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
- {-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
- --sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
- --first'[consider first N archives after other filters were applied]:N'\
- --last'[consider last N archives after other filters were applied]:N'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- $borg_common_options
- ;;
- (diff)
- _arguments \
- '2:archives:__borg_archive'\
- '3:archives:__borg_archive2'\
- '*:path:_files'\
- --numeric-owner'[only obey numeric user and group identifiers]'\
- --same-chunker-params'[override check of chunker parameters.]'\
- --sort'[sort the output lines by file path.]'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- $borg_common_options
-
- ;;
- (delete)
- _arguments \
- '2:archives:__borg_archive'\
- '*:archives:archives'\
- --dry-run'[do not change the repository]'\
- {-s,--stats}'[print statistics for the deleted archive]'\
- --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.]'\
- --save-space'[work slower, but using less space]'\
- {-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
- {-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
- --sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
- --first'[consider first N archives after other filters were applied]:N'\
- --last'[consider last N archives after other filters were applied]:N'\
- $borg_common_options
- ;;
- (prune)
- _arguments \
- '2:archives:__borg_archive'\
- {-n,--dry-run}'[do not change repository]'\
- --force'[force pruning of corrupted archives]'\
- {-s,--stats}'[print statistics for the deleted archive]'\
- --list'[output verbose list of archives it keeps/prunes]'\
- --keep-within'[keep all archives within this time interval]:INTERVAL'\
- {--keep-last,--keep-secondly}'[number of secondly archives to keep]:N'\
- --keep-minutely'[number of minutely archives to keep]:N'\
- {-H,--keep-hourly}'[number of hourly archives to keep]:N'\
- {-d,--keep-daily}'[number of daily archives to keep]:N'\
- {-w,--keep-weekly}'[number of weekly archives to keep]:N'\
- {-m,--keep-monthly}'[number of monthly archives to keep]:N'\
- {-y,--keep-yearly}'[number of yearly archives to keep]:N'\
- --save-space'[work slower, but using less space]'\
- {-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
- {-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
- $borg_common_options
- ;;
- (compact)
- _arguments \
- '2:archives:__borg_archive'\
- --cleanup-commits'[cleanup commit-only 17-byte segment files]'\
- $borg_common_options
- ;;
- (info)
- _arguments \
- '2:archives:__borg_archive'\
- --json'[format output as JSON]'\
- {-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
- {-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
- --sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
- --first'[consider first N archives after other filters were applied]:N'\
- --last'[consider last N archives after other filters were applied]:N'\
- $borg_common_options
- ;;
- (mount)
- _arguments \
- '2:archives:__borg_archive'\
- '3:mountpoint:_files'\
- {-f,--foreground}'[stay in foreground, do not daemonize]'\
- -o'[Extra mount options]:options:(ac_attr_timeout= allow_damaged_files allow_other allow_root attr_timeout= auto auto_cache auto_unmount default_permissions entry_timeout= gid= group_id= kernel_cache max_read= negative_timeout= noauto noforget remember= remount rootmode= uid= umask= user user_id= versions)'\
- {-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
- {-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
- --sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
- --first'[consider first N archives after other filters were applied]:N'\
- --last'[consider last N archives after other filters were applied]:N'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- --strip-components'[Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.]:NUMBER'\
- $borg_common_options
- ;;
- (umount)
- _arguments \
- '2:mountpoint:_files'\
- $borg_common_options
- ;;
- (key)
- case $keyCommand in
- (change-passphrase)
- _arguments \
- '2:subCommand:(change-passphrase import export)'\
- '3:archives:__borg_archive'\
- $borg_common_options
- ;;
- (export)
- _arguments \
- '2:subCommand:(change-passphrase import export)'\
- '3:archives:__borg_archive'\
- '4:path:_files'\
- --paper'[Create an export suitable for printing and later type-in]'\
- --qr-html'[Create an html file suitable for printing and later type-in or qr scan]'\
- $borg_common_options
- ;;
- (import)
- _arguments \
- '2:subCommand:(change-passphrase import export)'\
- '3:archives:__borg_archive'\
- '4:path:_files'\
- --paper'[interactively import from a backup done with --paper]'\
- $borg_common_options
- ;;
- *)
- _arguments \
- '2:subCommand:(change-passphrase import export)'\
- $borg_common_options
- ;;
- esac
- ;;
- (upgrade)
- _arguments \
- '2:archives:__borg_archive'\
- {-n,--dry-run}'[do not change repository]'\
- --inplace'[rewrite repository in place, with no chance of going back to older versions of the repository.]'\
- --force'[Force upgrade]'\
- --tam'[Enable manifest authentication (in key and cache).]'\
- --disable-tam'[Disable manifest authentication (in key and cache).]'\
- $borg_common_options
- ;;
- (recreate)
- _arguments \
- '2:archives:__borg_archive'\
- '3:path:_files'\
- --list'[output verbose list of items (files, dirs, ...)]'\
- --filter'[only display items with the given status characters]:STATUSCHARS'\
- {-n,--dry-run}'[do not create a backup archive]'\
- {-s,--stats}'[print statistics at end]'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- --exclude-caches'[exclude directories that contain a CACHEDIR.TAG file ]'\
- --exclude-if-present'[exclude directories that are tagged by containing a filesystem object with the given NAME]:NAME'\
- --keep-exclude-tags'[if tag objects are specified with --exclude-if-present, don’t omit the tag objects themselves]'\
- --target'[create a new archive with the name ARCHIVE]:ARCHIVE'\
- {-c,--checkpoint-interval}'[write checkpoint every SECONDS seconds]:SECONDS'\
- --comment'[add a comment text to the archive]:COMMENT'\
- --timestamp'[manually specify the archive creation date/time]:TIMESTAMP'\
- {-C,--compression}'[select compression algorithm]:COMPRESSION'\
- --recompress'[recompress data chunks according to --compression if if-different]:params:(if-different always)'\
- --chunker-params'[pecify the chunker parameters]:PARAMS'\
- $borg_common_options
- ;;
- (export-tar)
- _arguments \
- '2:archives:__borg_archive'\
- '3:tar:_files'\
- '4:path:_files'\
- --tar-filter'[filter program to pipe data through]'\
- --list'[output verbose list of items (files, dirs, ...)]'\
- {-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
- --exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
- --pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
- --patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
- --strip-components'[Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.]:NUMBER'\
- $borg_common_options
- ;;
- (serve)
- _arguments \
- --restrict-to-path'[restrict repository access to PATH]:_files'\
- --restrict-to-repository'[restrict repository access]:_files'\
- --append-only'[only allow appending to repository segment files]'\
- --storage-quota'[Override storage quota of the repository]:QUOTA'\
- $borg_common_options
- ;;
- (config)
- _arguments \
- '2:archives:__borg_archive'\
- '3:name:NAME'\
- '4:value:VALUE'\
- {-c,--cache}'[get and set values from the repo cache]'\
- {-d,--delete}'[delete the key from the config]'\
- --list'[list the configuration of the repo]'\
- $borg_common_options
- ;;
- (with-lock)
- _arguments \
- '(-)2:archives:__borg_archive'\
- $borg_common_options
- #'3:command:_command_names -e'\
- #'4:arguments:_normal'
- #TODO Debug this, getting "_tags:comptags:36: nesting level too deep" error
- ;;
- (break-lock)
- _arguments \
- '2:archives:__borg_archive'\
- $borg_common_options
- ;;
- (benchmark)
- _arguments \
- '2:type:(crud)'\
- '3:repo:_files'\
- '4:path:_files'\
- $borg_common_options
- ;;
- (help)
- _arguments \
- '2:type:(patterns placeholders compression )'\
- $borg_common_options
- ;;
- *)
- commands=(
- 'init:initialize empty repository'
- 'create:create backup'
- 'extract:extract archive contents'
- 'check:verify repository'
- 'rename:rename archive'
- 'list:list archive or repository contents'
- 'diff:find differences in archive contents'
- 'delete:delete archive'
- 'prune:prune archives'
- 'compact:free repository space'
- 'info:show repository or archive information'
- 'mount:mount repository'
- 'umount:umount repository'
- 'key:manage repository key'
- 'upgrade:upgrade repository format'
- 'recreate:recreate contents of existing archives'
- 'export-tar:create tarball from archive'
- 'serve:start repository server process'
- 'config:get/set options in repo/cache config'
- 'with-lock:run user command with lock held'
- 'break-lock:break repository and cache locks'
- 'benchmark:benchmark command'
- 'help:miscellaneous help'
- )
-
- _describe 'values' commands
- _arguments $borg_common_options
-
- ;;
+ _arguments -s -w -C : \
+ $common_options \
+ ': :->command' \
+ '*:: :->option-or-argument' && ret=0
+
+ case $state in
+ (command)
+ debug_commands=(
+ 'info:show system infos for debugging / bug reports'
+ 'dump-archive-items:dump archive items (metadata)'
+ 'dump-archive:dump decoded archive metadata'
+ 'dump-manifest:dump decoded repository metadata'
+ 'dump-repo-objs:dump repo objects'
+ 'search-repo-objs:search repo objects'
+ 'get-obj:get object from repository'
+ 'put-obj:put object to repository'
+ 'delete-obj:delete object from repository'
+ 'refcount-obj:show refcount for object from repository'
+ 'convert-profile:convert Borg profile to Python profile'
+ )
+ _describe -t commands 'command' debug_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext="${curcontext%:*}-$line[1]:"
+
+ case $line[1] in
+ (info)
+ _arguments -s -w -S : \
+ $common_options && ret=0
+ ;;
+ (dump-archive-items)
+ _arguments -s -w -S : \
+ $common_options \
+ ':ARCHIVE: _borg_repository_or_archive -a' && ret=0
+ ;;
+ (dump-archive)
+ _arguments -s -w -S : \
+ $common_options \
+ ':ARCHIVE: _borg_repository_or_archive -a' \
+ ':PATH:_files' && ret=0
+ ;;
+ (dump-manifest)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' \
+ ':PATH:_files' && ret=0
+ ;;
+ (dump-repo-objs)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' && ret=0
+ ;;
+ (search-repo-objs)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' \
+ ':WANTED (hex or string):' && ret=0
+ ;;
+ (get-obj)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' \
+ ':ID (hex object):' \
+ ':PATH:_files' && ret=0
+ ;;
+ (put-obj)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' \
+ '*:PATH:_files' && ret=0
+ ;;
+ (delete-obj)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' \
+ '*:ID (hex object):' && ret=0
+ ;;
+ (refcount-obj)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' \
+ '*:ID (hex object):' && ret=0
+ ;;
+ (convert-profile)
+ _arguments -s -w -S : \
+ $common_options \
+ ':INPUT:_files' \
+ ':OUTPUT:_files' && ret=0
+ ;;
+ (*)
+ if ! _call_function ret _borg_debug_$line[1]; then
+ _default && ret=0
+ fi
+ ;;
esac
+ ;;
+ esac
+
+ return ret
+}
+
+(( $+functions[_borg-delete] )) ||
+_borg-delete() {
+ local -a common_options common_archive_filters_options common_dry_run_stats_options
+ __borg_setup_common_options
+ __borg_setup_common_archive_filters_options
+ __borg_setup_common_dry_run_stats_options
+
+ _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.]' \
+ '--keep-security-info[keep the local security info when deleting a repository]' \
+ '--save-space[work slower, but using less space]' \
+ $common_archive_filters_options \
+ $common_options \
+ ':REPOSITORY_OR_ARCHIVE: _borg_repository_or_archive' \
+ '*:ARCHIVE: _borg_archive "${line[1]%%::*}"'
+}
+
+(( $+functions[_borg-diff] )) ||
+_borg-diff() {
+ local -a common_options common_exclude_options
+ __borg_setup_common_options
+ __borg_setup_common_exclude_options
+
+ _arguments -s -w -S : \
+ '--numeric-owner[only obey numeric user and group identifiers]' \
+ '--same-chunker-params[override check of chunker parameters]' \
+ '--sort[sort the output lines by file path]' \
+ $common_exclude_options \
+ $common_options \
+ ':ARCHIVE1: _borg_repository_or_archive -a' \
+ ':ARCHIVE2: _borg_archive "${line[1]%%::*}"' \
+ '*: : _borg_style_selector_or_archive_files -e "$line[1]" pp'
+}
+
+(( $+functions[_borg-export-tar] )) ||
+_borg-export-tar() {
+ local -a common_options common_exclude_extract_options
+ __borg_setup_common_options
+ __borg_setup_common_exclude_extract_options
+
+ _arguments -s -w -S : \
+ '--tar-filter[filter program to pipe data through]: :_cmdstring' \
+ '--list[output verbose list of items (files, dirs, ...)]' \
+ $common_exclude_extract_options \
+ $common_options \
+ ':ARCHIVE: _borg_repository_or_archive -a' \
+ ':FILE:_files' \
+ '*: : _borg_style_selector_or_archive_files -e "$line[1]" pp'
+}
+
+(( $+functions[_borg-extract] )) ||
+_borg-extract() {
+ local -a common_options common_exclude_extract_options
+ __borg_setup_common_options
+ __borg_setup_common_exclude_extract_options
+
+ _arguments -s -w -S : \
+ '--list[output verbose list of items (files, dirs, ...)]' \
+ '(-n --dry-run)'{-n,--dry-run}'[do not actually change any files]' \
+ '--numeric-owner[only obey numeric user and group identifiers]' \
+ '--nobsdflags[deprecated, use --noflags instead]' \
+ '--noflags[do not extract/set flags (e.g. NODUMP, IMMUTABLE)]' \
+ '--stdout[write all extracted data to stdout]' \
+ '--sparse[create holes in output sparse file from all-zero chunks]' \
+ $common_exclude_extract_options \
+ $common_options \
+ ':ARCHIVE: _borg_repository_or_archive -a' \
+ '*: : _borg_style_selector_or_archive_files -e "$line[1]" pp'
+}
+
+(( $+functions[_borg-help] )) ||
+_borg-help() {
+ local -a common_options
+ __borg_setup_common_options
+
+ _arguments -s -w -S : \
+ '--epilog-only' \
+ '--usage-only' \
+ $common_options \
+ ':: : _alternative "topics:TOPIC:(patterns placeholders compression)" ": :_borg_commands"'
+}
+
+(( $+functions[_borg-info] )) ||
+_borg-info() {
+ local -a common_options common_archive_filters_options
+ __borg_setup_common_options
+ __borg_setup_common_archive_filters_options
+
+ _arguments -s -w -S : \
+ '--json[format output as JSON]' \
+ $common_archive_filters_options \
+ $common_options \
+ '::REPOSITORY_OR_ARCHIVE: _borg_repository_or_archive'
+}
+
+(( $+functions[_borg-init] )) ||
+_borg-init() {
+ local -i ret=1
+ local -a common_options common_init_options
+ __borg_setup_common_options
+ __borg_setup_common_init_options
+
+ # special handling for the required optional argument
+ if (( ! ${words[(I)(-e|--encryption)(|=*)]} )); then
+ local desc='select encryption key mode'
+ local -a long=( "--encryption:$desc" ) short=( "-e:$desc" ) remove_chars=( -r '= \t\n\-' )
+ _describe -t required-options 'required option' long -S '=' $remove_chars -- short $remove_chars && ret=0
+ fi
+
+ _arguments -s -w -S : \
+ '(-e --encryption)'{-e,--encryption}'=[select encryption key mode (required)]:MODE:(none keyfile keyfile-blake2 repokey repokey-blake2 authenticated authenticated-blake2)' \
+ $common_init_options \
+ '--make-parent-dirs[create parent directories]' \
+ '::REPOSITORY:_directories' && ret=0
+
+ return ret
+}
+
+(( $+functions[_borg-key] )) ||
+_borg-key() {
+ local -a state line common_options
+ local curcontext="$curcontext" state_descr
+ declare -A opt_args
+ local -i ret=1
+ __borg_setup_common_options
+
+ _arguments -s -w -C : \
+ $common_options \
+ ': :->command' \
+ '*:: :->option-or-argument' && ret=0
+
+ case $state in
+ (command)
+ local -a key_commands=(
+ 'change-passphrase:Change repository key file passphrase'
+ 'export:Export the repository key for backup'
+ 'import:Import the repository key from backup'
+ 'migrate-to-repokey:Migrate passphrase -> repokey'
+ )
+ _describe -t commands 'command' key_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext="${curcontext%:*}-$line[1]:"
+
+ case $line[1] in
+ (change-passphrase)
+ _arguments -s -w -S : \
+ $common_options \
+ ': :_borg_repository' && ret=0
+ ;;
+ (export)
+ _arguments -s -w -S : \
+ '--paper[create an export suitable for printing and later type-in]' \
+ '--qr-html[create an html file suitable for printing and later type-in or qr scan]' \
+ $common_options \
+ ': :_borg_repository' \
+ '::PATH:_files' && ret=0
+ ;;
+ (import)
+ _arguments -s -w -S : \
+ '--paper[interactively import from a backup done with --paper]' \
+ $common_options \
+ ': :_borg_repository' \
+ '::PATH:_files' && ret=0
+ ;;
+ (migrate-to-repokey)
+ _arguments -s -w -S : \
+ $common_options \
+