Ignore:
Timestamp:
06/13/20 18:55:36 (4 years ago)
Author:
nanardon
Message:

Add config command to la-cli

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Base.pm

    r2285 r2396  
    5858 
    5959            $env->Help(@_); 
     60        }, 
     61    }); 
     62 
     63=head3 config 
     64 
     65=over 4 
     66 
     67=item config objects 
     68 
     69List supported objects type 
     70 
     71=item config objects OTYPE 
     72 
     73List attribute for OTYPE 
     74 
     75=back 
     76 
     77=cut 
     78 
     79    $self->add_func('config', { 
     80        completion => sub { 
     81            if (!$_[2]) { 
     82                return qw(objects); 
     83            } elsif ( $_[2] eq 'objects' ) { 
     84                if (! $_[3] ) { 
     85                    return $_[0]->base->list_supported_objects; 
     86                } 
     87            } 
     88        }, 
     89        code => sub { 
     90            my ($self, $cmd, @args) = @_; 
     91            if (!$cmd) { 
     92                print $OUT "No command given"; 
     93            } elsif ($cmd eq 'objects') { 
     94                if ( $args[0] ) { 
     95                    my $labase = $_[0]->base; 
     96                    foreach(sort $labase->list_canonical_fields($args[0], 'a')) { 
     97                        my $attr = $labase->attribute($args[0], $_); 
     98                        printf $OUT "%s   %s\n", ($attr ? ($attr->ro ? 'r ' : 'rw') : '  '), $_; 
     99                    } 
     100                } else { 
     101                    print $OUT "Supported objects type: "; 
     102                    print $OUT join(', ', $self->base->list_supported_objects); 
     103                    print $OUT "\n"; 
     104                } 
     105            } else { 
     106                print $OUT "wrong argument\n"; 
     107            } 
    60108        }, 
    61109    }); 
     
    225273Instead displaying attribute list use C<format> as formating string 
    226274 
    227 =item recur 
     275=item --recur 
    228276 
    229277Dump object and all related objects 
Note: See TracChangeset for help on using the changeset viewer.