Shell completions for borg compact

This commit is contained in:
SanskritFritz 2019-02-08 16:44:36 +01:00
parent 0a97274bd1
commit 8435206cc3
3 changed files with 16 additions and 2 deletions

View File

@ -17,7 +17,7 @@ _borg()
# 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 config benchmark help"
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
@ -97,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}"
;;

View File

@ -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'
@ -220,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

View File

@ -58,7 +58,7 @@ _borg() {
--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 help)
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=""
@ -220,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'\
@ -388,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'