Ignore:
Timestamp:
02/21/19 12:08:14 (5 years ago)
Author:
nanardon
Message:

Add a way to factorize code

File:
1 edited

Legend:

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

    r2209 r2211  
    161161        }, 
    162162    }); 
     163 
     164    $self->add_func( 
     165        'query' => { 
     166            proxy => '*', 
     167            help  => 'show attribute', 
     168            completion => sub { }, 
     169            code => sub { 
     170                my $env = shift; 
     171                my @args = $self->getoption({ 'o|object=s' => \my $otype }, @_); 
     172                $otype ||= 'user'; 
     173 
     174                my $objs = $self->Context->{objs}; 
     175 
     176                if (! $objs ) { 
     177                    foreach my $name (@args) { 
     178                        my $obj = $self->base->get_object( $otype, $name) or do { 
     179                            next; 
     180                        }; 
     181                        push(@{ $objs }, $obj); 
     182                    } 
     183                } 
     184 
     185                foreach (@{ $objs }) { 
     186                    $self->print($_->dump); 
     187                } 
     188            }, 
     189        } 
     190    ); 
    163191} 
    164192 
Note: See TracChangeset for help on using the changeset viewer.