Changeset 333
- Timestamp:
- 08/13/09 16:22:02 (15 years ago)
- Location:
- LATMOS-Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/bin/la-query
r313 r333 21 21 'b|base=s' => \my $base, 22 22 'o|object=s' => \my $otype, 23 'e|empty' => \my $empty_attr, 24 'o|ro' => \my $with_ro, 23 25 'help' => sub { pod2usage(0) }, 24 26 ) or pod2usage(); … … 42 44 Query should be performed on this objects. Default is to user 'User' object. 43 45 46 =item e|empty 47 48 Include also unset attributes 49 50 =item o|ro 51 52 Include also read-only attributes as comment 53 44 54 =back 45 55 … … 54 64 die "Object $otype $ouid not found\n"; 55 65 }; 56 foreach ($labase->list_canonical_fields($otype, 'r')) { 57 my $val = $obj->get_c_field($_); 58 printf( 59 " %s: %s\n", 60 $_, 61 ref $val ? join(', ', @$val) : ($val || 'N/A') 62 ); 63 } 66 $obj->text_dump(*STDOUT, 67 { 68 empty_attr => $empty_attr, 69 only_rw => !$with_ro, 70 } 71 ); 64 72 } else { 65 73 foreach (sort $labase->list_objects($otype)) { -
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r331 r333 375 375 } 376 376 377 sub text_dump { 378 my ($self, $handle, $options, $base) = @_; 379 380 my $otype = $self->type; 381 $base ||= $self->base; 382 383 foreach my $attr (sort { $a cmp $b } $base->list_canonical_fields($otype, 384 $options->{only_rw} ? 'rw' : 'r')) { 385 if (ref $self) { 386 my $wok = $self->get_field_name($attr, 'w'); 387 my $val = $self->get_c_field($attr); 388 if ($val || $options->{empty_attr}) { 389 my @vals = ref $val ? @{ $val } : $val; 390 foreach (@vals) { 391 printf($handle "%s%s: %s\n", 392 $wok ? '' : '# (ro) ', 393 $attr, $_ || ''); 394 } 395 } 396 } 397 } 398 } 399 377 400 1; 378 401
Note: See TracChangeset
for help on using the changeset viewer.