Changeset 2374


Ignore:
Timestamp:
06/02/20 18:52:41 (4 years ago)
Author:
nanardon
Message:

Add completion on attributes to la-cli search()

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
2 edited

Legend:

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

    r2309 r2374  
    8787                if(!$_[2]) { 
    8888                    return $_[0]->base->list_supported_objects 
    89                 } else { return() } 
     89                } else { 
     90                    return( 
     91                        map { ( $_ . '=', $_ . '~' ) } $_[0]->base->list_canonical_fields($_[2], 'r') 
     92                    ); 
     93                } 
    9094            }, 
    9195            code => sub { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Object.pm

    r2341 r2374  
    9595        } 
    9696    ); 
     97    $self->add_func('search', { 
     98        help => 'search objecttype filter1 [filter2...] - search object according filter', 
     99        completion => sub { 
     100 
     101            return( 
     102                map { ( $_ . '=', $_ . '~' ) } $_[0]->base->list_canonical_fields($_[0]->{_otype}, 'r') 
     103            ); 
     104        }, 
     105        code => sub { 
     106            my ($self, @args) = @_; 
     107            if ($_[1]) { 
     108                my @res = $self->base->search_objects($self->{_otype}, @args); 
     109                print $OUT map { "$_\n" } @res; 
     110                $self->{_lastsearch} = \@res; 
     111                $self->{_lastsearchtype} = $args[0]; 
     112            } else { 
     113                print $OUT "Object type missing\n"; 
     114            } 
     115        }, 
     116    }); 
     117 
    97118    $self->add_func('sort', { 
    98119        help => 'Sort the selection according attribute', 
Note: See TracChangeset for help on using the changeset viewer.