Ignore:
Timestamp:
02/21/19 22:13:00 (5 years ago)
Author:
nanardon
Message:

Add ability to call parent Envirronment (../func)

File:
1 edited

Legend:

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

    r2215 r2216  
    2727 
    2828has Context => ( is => 'ro', isa => 'LATMOS::Accounts::Cli::Context' ); 
     29has Parent  => ( is => 'ro' ); 
    2930 
    3031=head1 FUNCTIONS 
     
    379380    my ($self, $lastw, $name, @args) = @_; 
    380381    if (!$name) { 
    381         return grep { /^\Q$lastw\E/ } sort 
    382             (keys %{ $self->{funcs} || {}}); 
     382        if ($lastw =~ m!^\.\./?(.*)$!) { 
     383            if ($self->Parent) { 
     384                return map { "../$_" } $self->Parent->complete($1, $name, @args); 
     385            } else { 
     386                return (); 
     387            } 
     388        } else { 
     389            return grep { /^\Q$lastw\E/ } sort 
     390                (keys %{ $self->{funcs} || {}}); 
     391        } 
     392    } elsif ($name =~ m!^../(.*)$!) { 
     393        if ($self->Parent) { 
     394            return $self->Parent->complete($lastw, $1, @args); 
     395        } else { 
     396            return (); 
     397        } 
    383398    } elsif ($self->{funcs}{$name}{alias}) { 
    384399        $self->complete($lastw, @{$self->{funcs}{$name}{alias}}, @args); 
     
    400415    return if (!$name); 
    401416 
    402     if (grep { m/^(-h|--help)$/ } @args) { 
     417    if ($name =~ m!^../(.*)$!) { 
     418        if ($self->Parent) { 
     419            $self->Parent->run($1, @args); 
     420        } else { 
     421            $self->print("No parent envirronment to call function\n"); 
     422        } 
     423    } elsif (grep { m/^(-h|--help)$/ } @args) { 
    403424        $self->Help($name); 
    404425    } elsif (!exists($self->{funcs}{$name})) { 
Note: See TracChangeset for help on using the changeset viewer.