Changeset 2401


Ignore:
Timestamp:
06/15/20 19:10:38 (4 years ago)
Author:
nanardon
Message:

Handle recursive completion on search cli command

File:
1 edited

Legend:

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

    r2400 r2401  
    130130            help => 'search objecttype filter1 [filter2...] - search object according filter', 
    131131            completion => sub { 
     132                my ($self, $ritem, $rotype) = @_; 
    132133                if(!$_[2]) { 
    133                     return $_[0]->base->list_supported_objects 
    134                 } else { 
     134                    return $self->base->list_supported_objects 
     135                } else { 
     136                    my $parse; 
     137                    $parse = sub { 
     138                        my ($otype, $item) = @_; 
     139                        $item ||= ''; 
     140                        my ($NegFilter, $attr, $dot, $attrref, $operator, $val) = $item =~ /^([\!\+\-]?)(\w+)(?:(\.)([\.\w]+))?(?:([^\w*]+)(.+))?$/; 
     141                        if ($dot) { 
     142                            my $attribute = $self->base->attribute($otype, $attr) or 
     143                                return ($self->base->list_canonical_fields( $otype, 'r' ) ); 
     144                            my $refotype  = $attribute->reference; 
     145                            return map { "$attr." . $_ } $parse->($refotype, "$attrref$operator$val" ); 
     146                        } else { 
     147                            return($self->base->list_canonical_fields($otype, 'r')); 
     148                        } 
     149 
     150                    }; 
    135151                    return( 
    136152                        map { $_, "!$_", "-$_", "+$_" } 
    137                         map { ( $_ . '=', $_ . '~' ) } $_[0]->base->list_canonical_fields($_[2], 'r') 
     153                        map { ( $_ . '=', $_ . '~' ) } $parse->( $rotype, $ritem ) 
    138154                    ); 
    139155                } 
Note: See TracChangeset for help on using the changeset viewer.