Changeset 999 for trunk


Ignore:
Timestamp:
05/19/12 09:35:50 (12 years ago)
Author:
nanardon
Message:
  • simplify la-config, then aovid redundancy with la-attributes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/bin/la-config

    r985 r999  
    1313=head1 SYNOPSIS 
    1414 
    15 List supported base, synchronisation, objects and attributes 
     15List setup base, synchronisation 
    1616 
    17     la-config [option] [object] 
     17    la-config [option] 
    1818 
    1919=cut 
     
    2121GetOptions( 
    2222    'c|config=s' => \my $config, 
    23     'lb'         => \my $listbases, 
    2423    'ls'         => \my $listsynchros, 
    2524    'base=s'     => \my $base, 
     
    3938Perform query on this base 
    4039 
    41 =item --lb 
    42  
    43 List base setup in config 
    44  
    4540=item --ls 
    4641 
     
    5348my $LA = LATMOS::Accounts->new($config, noacl => 1); 
    5449 
    55 if ($listbases) { 
    56     my $default = $LA->default_base_name || ''; 
    57     print "Bases:\n"; 
    58     foreach ($LA->list_bases) { 
    59         printf("  %s %s (%s)\n", 
    60             ($_ eq $default ? '*' : ' '), 
    61             $_, 
    62             $LA->val($_, 'type', 'Err: no type') 
    63         ); 
    64     } 
    65 } 
    6650if ($listsynchros) { 
    6751    my $default_sync = $LA->default_synchro_name || ''; 
     
    7559        ); 
    7660    } 
    77 } 
    78 if (!($listsynchros || $listbases)) { 
    79     if (my $otype = $ARGV[0]) { 
    80         my $labase = $base ? $LA->base($base) : $LA->default_base; 
    81         printf "Supported field for object type %s (base %s)\n", 
    82         $otype, 
    83         $base ? $base : $LA->default_base_name; 
    84         foreach($labase->list_canonical_fields($otype, 'a')) { 
    85                 my $attr = $labase->attribute($otype, $_); 
    86             printf( 
    87                 "  %s (%s%s)\n", $_, 
    88                 'r', 
    89                 ($attr->readonly ? 'w' : ' '), 
    90             ) 
    91         } 
    92     } else { 
    93         my $labase = $base ? $LA->base($base) : $LA->default_base 
    94             or die "Cannot instanciate " . 
    95             $base ? $base : $LA->default_base_name . "\n"; 
    96         printf "Supported object type by base %s\n", 
    97             $base ? $base : $LA->default_base_name; 
    98         print "  $_\n" foreach($labase->ordered_objects); 
     61} else { 
     62    my $default = $LA->default_base_name || ''; 
     63    print "Bases:\n"; 
     64    foreach ($LA->list_bases) { 
     65        printf("  %s %s (%s)\n", 
     66            ($_ eq $default ? '*' : ' '), 
     67            $_, 
     68            $LA->val($_, 'type', 'Err: no type') 
     69        ); 
    9970    } 
    10071} 
Note: See TracChangeset for help on using the changeset viewer.