refactor print_pending_delete slightly

while this was much better than the old mess from
parse_pending_delete it still was a bit much nested into one line.

split that up a bit, add a render_key helper which does the clunky
"add !" check and just call that one in the map {}

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-10-18 17:15:46 +02:00
parent c29213f0ef
commit 51088c75f2

View File

@ -92,7 +92,14 @@ sub parse_pending_delete {
sub print_pending_delete {
my ($class, $delete_hash) = @_;
join ",", map { ( $delete_hash->{$_}->{force} ? '!' : '' ) . $_ } keys %$delete_hash;
my $render_key = sub {
my $key = shift;
$key = "!$key" if $delete_hash->{$key}->{force};
return $key;
};
join (',', map { $render_key->($_) } keys %$delete_hash);
}
sub add_to_pending_delete {