Changeset 455


Ignore:
Timestamp:
09/10/09 22:29:54 (15 years ago)
Author:
nanardon
Message:
  • make la-config usable
File:
1 edited

Legend:

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

    r128 r455  
    1313=head1 SYNOPSIS 
    1414 
    15 Show configured bases: 
     15List supported base, synchronisation, objects and attributes 
    1616 
    17     la-config 
    18  
    19 List supported attribute: 
    20  
    21     la-config [option] att 
    22     la-config [option] att objects_type 
     17    la-config [option] [object] 
    2318 
    2419=cut 
     
    2621GetOptions( 
    2722    'c|config=s' => \my $config, 
    28     'b|base=s'   => \my $base, 
     23    'lb'         => \my $listbases, 
     24    'ls'         => \my $listsynchros, 
     25    'base=s'     => \my $base, 
    2926    'help'       => sub { pod2usage(0) }, 
    3027) or pod2usage(); 
     
    4037Perform query on this base 
    4138 
     39 
     40=item --lb 
     41 
     42List base setup in config 
     43 
     44=item --ls 
     45 
     46List synchronisation setup in config 
     47 
    4248=cut 
    4349 
    4450my $LA = LATMOS::Accounts->new($config); 
    4551 
    46 my $action = shift(@ARGV) || ''; 
    47 for ($action) { 
    48     m/^$/ and do { 
    49         my $default = $LA->default_base_name || ''; 
    50         print "Bases:\n"; 
    51         foreach ($LA->list_bases) { 
    52             printf("  %s %s (%s)\n", 
    53                 ($_ eq $default ? '*' : ' '), 
    54                 $_, 
    55                 $LA->val($_, 'type', 'Err: no type') 
    56             ); 
    57         } 
    58         my $default_sync = $LA->default_synchro_name || ''; 
    59         print "Syncro:\n"; 
    60         foreach ($LA->list_synchro) { 
    61             printf("  %s %s (%s => %s)\n", 
    62                 ($_ eq $default_sync ? '*' : ' '), 
    63                 $_, 
    64                 $LA->val("sync:$_", 'from', 'Err: No from'), 
    65                 join(', ', $LA->val("sync:$_", 'to', 'Err: No to')), 
    66             ); 
    67         } 
    68         last; 
    69     }; 
    70     m/^att(ributes)?$/ and do { 
     52if ($listbases) { 
     53    my $default = $LA->default_base_name || ''; 
     54    print "Bases:\n"; 
     55    foreach ($LA->list_bases) { 
     56        printf("  %s %s (%s)\n", 
     57            ($_ eq $default ? '*' : ' '), 
     58            $_, 
     59            $LA->val($_, 'type', 'Err: no type') 
     60        ); 
     61    } 
     62} 
     63if ($listsynchros) { 
     64    my $default_sync = $LA->default_synchro_name || ''; 
     65    print "Syncro:\n"; 
     66    foreach ($LA->list_synchro) { 
     67        printf("  %s %s (%s => %s)\n", 
     68            ($_ eq $default_sync ? '*' : ' '), 
     69            $_, 
     70            $LA->val("sync:$_", 'from', 'Err: No from'), 
     71            join(', ', $LA->val("sync:$_", 'to', 'Err: No to')), 
     72        ); 
     73    } 
     74} 
     75if (!($listsynchros || $listbases)) { 
     76    if (my $otype = $ARGV[0]) { 
    7177        my $labase = $base ? $LA->base($base) : $LA->default_base; 
    72         if (my $otype = shift(@ARGV)) { 
    73             printf "Supported field for object type %s (base %s)\n", 
    74                 $otype, 
    75                 $base ? $base : $LA->default_base_name; 
    76             printf( 
    77                 "  %s (%s%s)\n", $_, 
    78                 ($labase->get_field_name($otype, $_, 'r') ? 'r' : ' '), 
    79                 ($labase->get_field_name($otype, $_, 'w') ? 'w' : ' '), 
    80             ) foreach($labase->list_canonical_fields($otype, 'a')); 
    81         } else { 
    82             printf "Supported object type by base %s\n", 
    83                 $base ? $base : $LA->default_base_name; 
    84             print "  $_\n" foreach($labase->list_supported_objects); 
    85         } 
    86     }; 
     78        printf "Supported field for object type %s (base %s)\n", 
     79        $otype, 
     80        $base ? $base : $LA->default_base_name; 
     81        printf( 
     82            "  %s (%s%s)\n", $_, 
     83            ($labase->get_field_name($otype, $_, 'r') ? 'r' : ' '), 
     84            ($labase->get_field_name($otype, $_, 'w') ? 'w' : ' '), 
     85        ) foreach($labase->list_canonical_fields($otype, 'a')); 
     86    } else { 
     87        my $labase = $base ? $LA->base($base) : $LA->default_base; 
     88        printf "Supported object type by base %s\n", 
     89        $base ? $base : $LA->default_base_name; 
     90        print "  $_\n" foreach($labase->list_supported_objects); 
     91    } 
    8792} 
Note: See TracChangeset for help on using the changeset viewer.