source: LATMOS-Accounts/bin/la-query-group @ 493

Last change on this file since 493 was 457, checked in by nanardon, 15 years ago
  • add options to not load acls, command line tools are superuser command, then skip acls checks
  • Property svn:executable set to *
File size: 1.3 KB
RevLine 
[440]1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8
9=head1 NAME
10
11    la-query - Tools to query base in LATMOS::Accounts system
12
13=head1 SYNOPSIS
14
15    la-query [options] [obj_id]
16
17=cut
18
19GetOptions(
20    'c|config=s' => \my $config,
21    'b|base=s'   => \my $base,
22    'help'       => sub { pod2usage(0) },
23) or pod2usage();
24
25$otype ||= 'user';
26
27=head1 OPTIONS
28
29=over 4
30
31=item -c|--config configfile
32
33Use this cofngiuration file instead the default one
34
35=item -b|--base basename
36
37Query this specific base instead default.
38
39=item -o|object object_type
40
41Query should be performed on this objects. Default is to user 'User' object.
42
43=item -e|--empty
44
45Include also unset attributes
46
47=item --ro
48
49Include also read-only attributes as comment
50
51=back
52
53=cut
54
[457]55my $LA = LATMOS::Accounts->new($config, noacl => 1);
[440]56my $labase = $base ? $LA->base($base) : $LA->default_base;
57$labase && $labase->load or die "Cannot load base";
58
59if (my $ouid = shift(@ARGV)) {
60    my $obj = $labase->get_object($otype, $ouid) or do {
61        die "Object $otype $ouid not found\n";
62    };
63    $obj->text_dump(*STDOUT,
64        {
65            empty_attr => $empty_attr,
66            only_rw => !$with_ro,
67        }
68    );
69} else {
70    foreach (sort $labase->list_objects($otype)) {
71        print "$_\n";
72    }
73}
Note: See TracBrowser for help on using the repository browser.