Bladeren bron

Merge pull request #4335 from SanskritFritz/master

master - Shell completions.
TW 6 jaren geleden
bovenliggende
commit
9259000d73
3 gewijzigde bestanden met toevoegingen van 46 en 5 verwijderingen
  1. 10 3
      scripts/shell_completions/bash/borg
  2. 19 0
      scripts/shell_completions/fish/borg.fish
  3. 17 2
      scripts/shell_completions/zsh/_borg

+ 10 - 3
scripts/shell_completions/bash/borg

@@ -12,12 +12,12 @@ _borg()
     local cur="${COMP_WORDS[COMP_CWORD]}"
     local prev="${COMP_WORDS[COMP_CWORD-1]}"
     local prevprev="${COMP_WORDS[COMP_CWORD-2]}"
-    local common_opts="-h --help --version --critical --error --warning --info -v --verbose --debug --debug-topic -p --progress --log-json --lock-wait --show-version --show-rc --umask --remote-path --remote-ratelimit --consider-part-files --debug-profile"
+    local common_opts="-h --help --version --critical --error --warning --info -v --verbose --debug --debug-topic -p --progress --log-json --lock-wait --show-version --show-rc --umask --remote-path --remote-ratelimit --consider-part-files --debug-profile --rsh"
     local opts="${common_opts}"
 
     # Commands
     if [[ ${COMP_CWORD} == 1 ]] ; then
-        local borg_commands="init create extract check rename list diff delete prune info mount umount key serve upgrade recreate export-tar with-lock break-lock benchmark config"
+        local borg_commands="init create extract check rename list diff delete prune compact info mount umount key serve upgrade recreate export-tar with-lock break-lock config benchmark help"
         COMPREPLY=( $(compgen -W "${borg_commands}" -- ${cur}) )
         compopt +o default
         return 0
@@ -32,6 +32,10 @@ _borg()
             COMPREPLY=( $(compgen -W "crud" -- ${cur}) )
             return 0
             ;;
+        'help')
+            COMPREPLY=( $(compgen -W "patterns placeholders compression" -- ${cur}) )
+            return 0
+            ;;
         '--encryption' | '-e')
             local encryption_modes="none keyfile keyfile-blake2 repokey repokey-blake2 authenticated authenticated-blake2"
             COMPREPLY=( $(compgen -W "${encryption_modes}" -- ${cur}) )
@@ -68,7 +72,7 @@ _borg()
     if [[ ${cur} == -* ]] ; then
         case "${COMP_LINE}" in
             *' init '*)
-                local opts="-e --encryption --append-only --storage-quota ${common_opts}"
+                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}"
@@ -93,6 +97,9 @@ _borg()
             *' prune '*)
                 local opts="-n --dry-run --force -s --stats --list --keep-within --keep-last --keep-secondly --keep-minutely -H --keep-hourly -d --keep-daily -w --keep-weekly -m --keep-monthly -y --keep-yearly --save-space -P --prefix -a --glob-archives ${common_opts}"
                 ;;
+            *' compact '*)
+                local opts="--cleanup-commits ${common_opts}"
+                ;;
             *' info '*)
                 local opts="--json -P --prefix -a --glob-archives --sort-by --first --last ${common_opts}"
                 ;;

+ 19 - 0
scripts/shell_completions/fish/borg.fish

@@ -16,6 +16,7 @@ complete -c borg -f -n __fish_is_first_token -a 'list' -d 'List archive or repos
 complete -c borg -f -n __fish_is_first_token -a 'diff' -d 'Find differences between archives'
 complete -c borg -f -n __fish_is_first_token -a 'delete' -d 'Delete a repository or archive'
 complete -c borg -f -n __fish_is_first_token -a 'prune' -d 'Prune repository archives'
+complete -c borg -f -n __fish_is_first_token -a 'compact' -d 'Free repository space'
 complete -c borg -f -n __fish_is_first_token -a 'info' -d 'Show archive details'
 complete -c borg -f -n __fish_is_first_token -a 'mount' -d 'Mount archive or a repository'
 complete -c borg -f -n __fish_is_first_token -a 'umount' -d 'Un-mount the mounted archive'
@@ -50,6 +51,17 @@ end
 complete -c borg -f -n __fish_is_first_token -a 'benchmark' -d 'Benchmark borg operations'
 complete -c borg -f -n __fish_borg_seen_benchmark -a 'crud' -d 'Benchmark borg CRUD operations'
 
+function __fish_borg_seen_help
+    if __fish_seen_subcommand_from help
+        and not __fish_seen_subcommand_from patterns placeholders compression
+        return 0
+    end
+    return 1
+end
+complete -c borg -f -n __fish_is_first_token -a 'help' -d 'Miscellaneous Help'
+complete -c borg -f -n __fish_borg_seen_help -a 'patterns' -d 'Help for patterns'
+complete -c borg -f -n __fish_borg_seen_help -a 'placeholders' -d 'Help for placeholders'
+complete -c borg -f -n __fish_borg_seen_help -a 'compression' -d 'Help for compression'
 
 # Common options
 complete -c borg -f -s h -l 'help'                  -d 'Show help information'
@@ -71,12 +83,14 @@ complete -c borg         -l 'remote-path'           -d 'Use PATH as remote borg
 complete -c borg -f      -l 'remote-ratelimit'      -d 'Set remote network upload RATE limit'
 complete -c borg -f      -l 'consider-part-files'   -d 'Treat part files like normal files'
 complete -c borg         -l 'debug-profile'         -d 'Write execution profile into FILE'
+complete -c borg         -l 'rsh'                   -d 'Use COMMAND instead of ssh'
 
 # borg init options
 set -l encryption_modes "none keyfile keyfile-blake2 repokey repokey-blake2 authenticated authenticated-blake2"
 complete -c borg -f -s e -l 'encryption'            -d 'Encryption key MODE' -a "$encryption_modes" -n "__fish_seen_subcommand_from init"
 complete -c borg -f      -l 'append-only'           -d 'Create an append-only mode repository'      -n "__fish_seen_subcommand_from init"
 complete -c borg -f      -l 'storage-quota'         -d 'Set storage QUOTA of the repository'        -n "__fish_seen_subcommand_from init"
+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"
@@ -207,6 +221,9 @@ complete -c borg -f      -l 'save-space'            -d 'Work slower but using le
 complete -c borg -f -s P -l 'prefix'                -d 'Only archive names starting with PREFIX'    -n "__fish_seen_subcommand_from prune"
 complete -c borg -f -s a -l 'glob-archives'         -d 'Only archive names matching GLOB'           -n "__fish_seen_subcommand_from prune"
 
+# borg compact options
+complete -c borg -f -s n -l 'cleanup-commits'       -d 'Cleanup commit-only segment files'          -n "__fish_seen_subcommand_from compact"
+
 # borg info options
 complete -c borg -f      -l 'json'                  -d 'Format output in json format'               -n "__fish_seen_subcommand_from info"
 # Archive filters
@@ -309,6 +326,8 @@ complete -c borg -f      -l 'list'                  -d 'List the configuration o
 # borg benchmark
 # no specific options
 
+# borg help
+# no specific options
 
 # List archives
 

+ 17 - 2
scripts/shell_completions/zsh/_borg

@@ -55,9 +55,10 @@ _borg() {
                              --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')
+                             --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 info mount umount key upgrade recreate export-tar serve config with-lock break-lock benchmark)
+    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=""
@@ -74,6 +75,7 @@ _borg() {
                 {-e,--encryption}'[select encryption key mode]:MODE'\
                 --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)
@@ -218,6 +220,12 @@ _borg() {
                 {-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'\
@@ -370,6 +378,11 @@ _borg() {
                 '4:path:_files'\
                 $borg_common_options
             ;;
+        (help)
+            _arguments \
+                '2:type:(patterns placeholders compression )'\
+                $borg_common_options
+            ;;
         *)
             commands=(
                 'init:initialize empty repository'
@@ -381,6 +394,7 @@ _borg() {
                 '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'
@@ -393,6 +407,7 @@ _borg() {
                 'with-lock:run user command with lock held'
                 'break-lock:break repository and cache locks'
                 'benchmark:benchmark command'
+                'help:miscellaneous help'
             )
 
             _describe 'values' commands