- Timestamp:
- 02/21/19 22:12:58 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-query
r1549 r2214 7 7 use Pod::Usage; 8 8 use LATMOS::Accounts::I18N; 9 use LATMOS::Accounts::Cli; 10 use LATMOS::Accounts::Cli::Context; 9 11 10 12 =head1 NAME … … 27 29 =cut 28 30 31 Getopt::Long::Configure("pass_through"); 29 32 GetOptions( 30 33 'c|config=s' => \my $config, 31 34 'b|base=s' => \my $base, 32 35 'o|object=s' => \my $otype, 33 'e|empty' => \my $empty_attr,34 'fmt=s' => \my $fmt,35 'filefmt=s' => \my $filefmt,36 'ro' => \my $with_ro,37 36 'no-unexp|wo-unexp' => \my $nounexp, 38 37 'with-unexp' => \my $unexp, … … 120 119 $labase->unexported($nounexp ? 0 : 1); 121 120 122 unless ($labase->is_supported_object($otype)) { 123 die "Unsupported object type `$otype'\n"; 124 } 125 126 if ($filefmt){ 127 open(my $hfmt, '<', $filefmt) or die "Cannot open $filefmt\n"; 128 $fmt ||= ''; # avoid undef warning 129 while (<$hfmt>) { 130 chomp($fmt .= $_); 131 } 132 close $hfmt; 133 } 121 my $Env = LATMOS::Accounts::Cli->new( 122 Context => LATMOS::Accounts::Cli::Context->new( 123 base => $labase, 124 ), 125 ); 134 126 135 127 if (@ARGV) { 136 foreach my $ouid (@ARGV) { 137 my $obj = $labase->get_object($otype, $ouid) or do { 138 die "Object $otype $ouid not found\n"; 139 }; 140 if ($fmt) { 141 print $obj->queryformat($fmt); 142 } else { 143 $obj->text_dump(*STDOUT, 144 { 145 empty_attr => $empty_attr, 146 only_rw => !$with_ro, 147 } 148 ); 149 } 150 } 128 $Env->run('query', '-o', $otype, @ARGV); 151 129 } else { 152 foreach (sort $labase->list_objects($otype)) { 153 if ($fmt) { 154 my $o = $labase->get_object($otype, $_) or next; 155 print $o->queryformat($fmt); 156 } else { 157 print "$_\n"; 158 } 159 } 130 $Env->run('ls', $otype, @ARGV); 160 131 }
Note: See TracChangeset
for help on using the changeset viewer.