Evaluate completion arguments when called

This makes the destinations update dynamically when they are added/removed.
Unquote the echo statement so that it is correctly paresd by the -a options.
This commit is contained in:
Sam Doran
2025-04-19 01:17:58 -04:00
parent 1a2958d42b
commit 0b97fa7114

View File

@@ -24,7 +24,7 @@ function __destination_ids
if string match -q -r '^ID' -- $line
# Got the destination ID
set -f ID "$(string match -r -g '^ID\s+:\s+(.*)$' $line | string trim)"
echo "$ID\t'$name $kind'"
echo $ID\t$name $kind
continue
end
end
@@ -96,7 +96,7 @@ complete -c tmutil -f -n __fish_use_subcommand -a localsnapshot -d 'Create new l
complete -c tmutil -f -n __fish_use_subcommand -a machinedirectory -d 'Print the path to the current machine directory'
complete -c tmutil -f -n __fish_use_subcommand -a removedestination -d 'Removes a backup destination'
complete -c tmutil -f -n '__fish_seen_subcommand_from removedestination' -a "$(__destination_ids)"
complete -c tmutil -f -n '__fish_seen_subcommand_from removedestination' -a '$(__destination_ids)'
complete -c tmutil -f -n __fish_use_subcommand -a removeexclusion -d 'Remove an exclusion'
complete -c tmutil -f -n '__fish_seen_subcommand_from removeexclusion' -s v -d 'Volume exclusion'
@@ -115,7 +115,7 @@ complete -c tmutil -f -n __fish_use_subcommand -a startbackup -d 'Begin a backup
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s a -l auto -d 'Automatic mode'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s b -l block -d 'Block until finished'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s r -l rotation -d 'Automatic rotation'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s d -l destination -r -a "$(__destination_ids)" -d 'Backup destination'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s d -l destination -r -a '$(__destination_ids)' -d 'Backup destination'
complete -c tmutil -f -n __fish_use_subcommand -a stopbackup -d 'Cancel a backup currently in progress'
@@ -128,7 +128,7 @@ complete -c tmutil -r -n __fish_use_subcommand -a verifychecksums -d 'Verify sna
complete -c tmutil -f -n __fish_use_subcommand -a version -d 'Print version'
complete -c tmutil -f -n __fish_use_subcommand -a setquota -d 'Set the quota for the destination in gigabytes'
complete -c tmutil -f -n '__fish_seen_subcommand_from setquota' -r -a "$(__destination_ids)"
complete -c tmutil -f -n '__fish_seen_subcommand_from setquota' -r -a '$(__destination_ids)'
complete -c tmutil -f -n '__fish_seen_subcommand_from destinationinfo isexcluded compare status' -s X -d 'Print as XML'
complete -c tmutil -f -n '__fish_seen_subcommand_from latestbackup listbackups' -s m -d 'Destination volume to list backups from'