@@ -8,6 +8,7 @@ use parent qw(WGDev::Command::Base);
8
8
9
9
sub config_options {
10
10
return qw(
11
+ directory|d
11
12
format|f=s
12
13
long|l
13
14
recursive|r
@@ -74,36 +75,42 @@ sub process {
74
75
$error ++;
75
76
next ;
76
77
}
77
- if ($show_header ) {
78
- print " $parent :\n " ;
78
+ if ($self -> option(' directory' )) {
79
+ my $parent_asset = $wgd -> asset-> find($parent );
80
+ print $self -> format_output( $format , $parent_asset ), " \n " ;
79
81
}
80
- my $child_iter = $asset -> getLineageIterator(
81
- [$relatives ],
82
- {
83
- $exclude_classes ? ( excludeClasses => $exclude_classes )
84
- : (),
85
- $include_only_classes
86
- ? ( includeOnlyClasses => $include_only_classes )
87
- : (),
88
- defined $limit
89
- && !defined $self -> {filter_match } ? ( limit => $limit )
90
- : (),
91
- $isa ? ( isa => $isa ) : (),
92
- } );
93
- while ( my $child = $child_iter -> () ) {
94
- next
95
- if !$self -> pass_filter($child );
96
-
97
- # Handle limit ourselves because smartmatch filtering happens
98
- # *after* getLineage returns its results
99
- last PARENT
100
- if defined $limit && $limit -- <= 0;
101
-
102
- my $output = $self -> format_output( $format , $child );
103
- print $output . " \n " ;
104
- }
105
- if (@parents ) {
106
- print " \n " ;
82
+ else {
83
+ if ($show_header ) {
84
+ print " $parent :\n " ;
85
+ }
86
+ my $child_iter = $asset -> getLineageIterator(
87
+ [$relatives ],
88
+ {
89
+ $exclude_classes ? ( excludeClasses => $exclude_classes )
90
+ : (),
91
+ $include_only_classes
92
+ ? ( includeOnlyClasses => $include_only_classes )
93
+ : (),
94
+ defined $limit
95
+ && !defined $self -> {filter_match } ? ( limit => $limit )
96
+ : (),
97
+ $isa ? ( isa => $isa ) : (),
98
+ } );
99
+ while ( my $child = $child_iter -> () ) {
100
+ next
101
+ if !$self -> pass_filter($child );
102
+
103
+ # Handle limit ourselves because smartmatch filtering happens
104
+ # *after* getLineage returns its results
105
+ last PARENT
106
+ if defined $limit && $limit -- <= 0;
107
+
108
+ my $output = $self -> format_output( $format , $child );
109
+ print $output . " \n " ;
110
+ }
111
+ if (@parents ) {
112
+ print " \n " ;
113
+ }
107
114
}
108
115
}
109
116
return (! $error );
@@ -154,16 +161,20 @@ sub format_output {
154
161
155
162
=head1 SYNOPSIS
156
163
157
- wgd ls [-l] [--format=<format>] [-r] <asset> [<asset> ...]
164
+ wgd ls [-d] [- l] [--format=<format>] [-r] <asset> [<asset> ...]
158
165
159
166
=head1 DESCRIPTION
160
167
161
- Lists children of WebGUI assets
168
+ Lists children of WebGUI asset(s), or just the asset(s) themselves
162
169
163
170
=head1 OPTIONS
164
171
165
172
=over 8
166
173
174
+ =item C<-d > C<--directory >
175
+
176
+ Print only the specified asset (similar to '-d' in ls(1)).
177
+
167
178
=item C<-l > C<--long >
168
179
169
180
Use long list format, which includes asset ID, URL, and title.
@@ -178,32 +189,38 @@ using C<%%>.
178
189
=item C<-r > C<--recursive >
179
190
180
191
Recursively list all descendants (by default we only list children).
192
+ Ignored when '-d' is set.
181
193
182
194
=item C<--includeOnlyClass= >
183
195
184
196
Specify one or more times to limit the results to a certain set of asset classes.
197
+ Ignored when '-d' is set.
185
198
186
199
=item C<--excludeClass= >
187
200
188
201
Specify one or more times to filter out certain asset class(es) from the results.
202
+ Ignored when '-d' is set.
189
203
190
204
=item C<--limit= >
191
205
192
- The maximum amount of entries to return
206
+ The maximum amount of entries to return.
207
+ Ignored when '-d' is set.
193
208
194
209
=item C<--isa= >
195
210
196
211
A class name where you can look for classes of a similar base class.
197
212
For example, if you're looking for Donations, Subscriptions, Products
198
213
and other subclasses of L<WebGUI::Asset::Sku> , then specify the
199
214
parameter C<--isa=WebGUI::Asset::Sku > .
215
+ Ignored when '-d' is set.
200
216
201
217
=item C<--filter= >
202
218
203
219
Apply smart match filtering against the results. Format looks like
204
220
C<%url% ~~ smartmatch > , where C<url > is the field to filter against,
205
221
and C<smartmatch > is either a Perl regular expression such as
206
222
C</(?i:partial_match)/ > or a string such as C<my_exact_match > .
223
+ Ignored when '-d' is set.
207
224
208
225
=back
209
226
@@ -215,10 +232,12 @@ the format to output as specified in the L<format option|/-f>.
215
232
=method C<option_filter ( $filter ) >
216
233
217
234
Takes a filter specification, verifies that it is specified properly, and saves it.
235
+ Ignored when '-d' is set.
218
236
219
237
=method C<pass_filter ( $asset ) >
220
238
221
239
Checks if a given asset passes the saved filter. Returns true or false.
240
+ Ignored when '-d' is set.
222
241
223
242
=cut
224
243
0 commit comments