@@ -2,6 +2,7 @@ package WGDev::Command::Trash;
2
2
# ABSTRACT: Trash assets by URL/assetId
3
3
use strict;
4
4
use warnings;
5
+ use WGDev::Command::Ls;
5
6
use 5.008008;
6
7
7
8
use parent qw( WGDev::Command::Base) ;
@@ -12,17 +13,29 @@ sub config_options {
12
13
return qw(
13
14
purge
14
15
restore
16
+ list
15
17
) ;
16
18
}
17
19
18
20
sub process {
19
21
my $self = shift ;
20
22
my $wgd = $self -> wgd;
21
- my @asset_specs = $self -> arguments;
23
+ if ($self -> option(' list' )) {
24
+ return $self -> list_trash;
25
+ }
26
+ else {
27
+ return $self -> trash;
28
+ }
29
+ }
30
+
31
+ sub trash {
32
+ my $self = shift ;
33
+ my $wgd = $self -> wgd;
22
34
my $error ;
23
35
my $method = $self -> option(' purge' ) ? ' purge'
24
36
: $self -> option(' restore' ) ? ' restore'
25
37
: ' trash' ;
38
+ my @asset_specs = $self -> arguments;
26
39
ASSET:
27
40
while ( my $asset_spec = shift @asset_specs ) {
28
41
my $asset ;
@@ -41,15 +54,33 @@ sub process {
41
54
return (! $error );
42
55
}
43
56
57
+ sub list_trash {
58
+ my $self = shift ;
59
+ my $wgd = $self -> wgd;
60
+ my $root = $wgd -> asset-> root;
61
+ my $trashed_assets = $root -> getAssetsInTrash();
62
+ my $ls = WGDev::Command::Ls-> new($wgd );
63
+ my $format = ' %assetId% %url:-35% %title%' ;
64
+ ASSET:
65
+ foreach my $asset ( @{ $trashed_assets } ) {
66
+ next ASSET unless $asset ;
67
+ my $output = $ls -> format_output( $format , $asset );
68
+ print $output . " \n " ;
69
+ }
70
+
71
+ return 1;
72
+ }
73
+
44
74
1;
45
75
46
76
=head1 SYNOPSIS
47
77
48
78
wgd trash [--purge] [--restore] <asset> [<asset> ...]
79
+ wgd trash [--list]
49
80
50
81
=head1 DESCRIPTION
51
82
52
- Puts assets into the trash, or purges them .
83
+ Methods for working with assets in the trash .
53
84
54
85
=head1 OPTIONS
55
86
@@ -63,6 +94,10 @@ Purges the assets from the system instead of putting it into the trash.
63
94
64
95
Restores the assets that have been trashed to the regular, published state.
65
96
97
+ =item C<--list >
98
+
99
+ Lists all assets in the trash.
100
+
66
101
=item C<< <asset> >>
67
102
68
103
Either an asset URL or an ID. As many can be specified as desired.
0 commit comments