Skip to content

Commit

Permalink
Merge pull request #4334 from SanskritFritz/1.1-maint
Browse files Browse the repository at this point in the history
1.1-maint shell completions for borg 1.1.9
  • Loading branch information
ThomasWaldmann authored Feb 8, 2019
2 parents 075600d + 071febd commit b5518b1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
10 changes: 7 additions & 3 deletions scripts/shell_completions/bash/borg
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand All @@ -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}) )
Expand Down Expand Up @@ -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}"
Expand Down
15 changes: 15 additions & 0 deletions scripts/shell_completions/fish/borg.fish
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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'
Expand All @@ -71,12 +82,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"
Expand Down Expand Up @@ -309,6 +322,8 @@ complete -c borg -f -l 'list' -d 'List the configuration o
# borg benchmark
# no specific options

# borg help
# no specific options

# List archives

Expand Down
12 changes: 10 additions & 2 deletions scripts/shell_completions/zsh/_borg
Original file line number Diff line number Diff line change
Expand Up @@ -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 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=""
Expand All @@ -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)
Expand Down Expand Up @@ -370,6 +372,11 @@ _borg() {
'4:path:_files'\
$borg_common_options
;;
(help)
_arguments \
'2:type:(patterns placeholders compression )'\
$borg_common_options
;;
*)
commands=(
'init:initialize empty repository'
Expand All @@ -393,6 +400,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
Expand Down

0 comments on commit b5518b1

Please sign in to comment.