Changeset 2464
- Timestamp:
- 03/24/21 11:55:24 (3 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli.pm
r2459 r2464 181 181 }, 182 182 }) if ($self->base->can('find_expired_users')); 183 183 184 $self->add_func('expires', { 184 185 help => 'expires [delay] - list account expiring before delay (default is 1 month)', … … 191 192 }, 192 193 }) if ($self->base->can('find_next_expire_users')); 193 $self->add_func('select', { 194 195 $self->add_func( 196 'select', 197 { 194 198 help => 'select object_type - select objects to perform action on it', 195 199 completion => sub { … … 231 235 )->cli(); 232 236 }, 233 }); 237 } 238 ); 234 239 235 240 =head2 testpass -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Base.pm
r2443 r2464 156 156 =cut 157 157 158 $self->add_func('quit', { 159 code => sub { $self->print("\n"); exit(0) }, }); 158 $self->add_func( 159 'quit', 160 { 161 code => sub { 162 $self->print("\n"); 163 $self->_exit(); 164 exit(0) 165 }, 166 } 167 ); 160 168 161 169 =head3 exit … … 165 173 =cut 166 174 167 $self->add_func('exit', { 168 code => sub { return "EXIT" }, }); 175 $self->add_func( 176 'exit', 177 { 178 code => sub { return "EXIT" }, 179 } 180 ); 181 182 =head3 top 183 184 Exit from any selection context 185 186 =cut 187 188 $self->add_func( 189 'top', 190 { 191 code => sub { return "TOP" }, 192 } 193 ); 169 194 170 195 =head3 ! … … 723 748 $self->Context->ReadHistory(); 724 749 $self->cli(); 725 if (! $self->Context->WriteHistory() ) { 726 warn "Cannot write history: $!\n"; 750 $self->_exit(); 751 } 752 753 sub _exit { 754 my ( $self ) = @_; 755 756 if ( -t ) { 757 if (! $self->Context->WriteHistory() ) { 758 warn "Cannot write history: $!\n"; 759 } 727 760 } 728 761 $self->Context->WritePreferences(); … … 741 774 742 775 while (1) { 743 $term->Attribs->{completion_function} = sub { 744 my ($Op, $Shell, @args) = $self->_parse_cmd_line(substr($_[1], 0, $_[2])); 745 $Op ||= ''; 746 my $attribs = $self->Context->Term->Attribs; 747 if ($Op eq '>') { 748 $term->completion_matches($Shell, $attribs->{'filename_completion_function'}); 749 } elsif ($Op eq '|') { 750 $term->completion_matches($Shell, $attribs->{'filename_completion_function'}); 751 } else { 752 $self->complete($_[0], @args); 753 } 754 }; 776 if ( -t ) { 777 $term->Attribs->{completion_function} = sub { 778 my ($Op, $Shell, @args) = $self->_parse_cmd_line(substr($_[1], 0, $_[2])); 779 $Op ||= ''; 780 my $attribs = $self->Context->Term->Attribs; 781 if ($Op eq '>') { 782 $term->completion_matches($Shell, $attribs->{'filename_completion_function'}); 783 } elsif ($Op eq '|') { 784 $term->completion_matches($Shell, $attribs->{'filename_completion_function'}); 785 } else { 786 $self->complete($_[0], @args); 787 } 788 }; 789 } 755 790 defined (my $line = $term->readline($self->prompt)) or do { 756 791 $self->print("\n"); … … 771 806 } 772 807 $self->rollback if (!$self->Context->TransMode); 773 if ($res && $res eq 'EXIT') { $self->print("\n"); return } 808 if ($res) { 809 if ( $res eq 'EXIT' ) { 810 $self->print("\n"); 811 return 812 } elsif ( $res eq 'TOP' ) { 813 if ( $self->isa('LATMOS::Accounts::Cli::Object') ) { 814 return 'TOP' 815 } else { 816 $self->print("\n"); 817 } 818 } 819 } 774 820 } 775 821 } … … 788 834 sub prompt { 789 835 my ($self) = @_; 836 if (! -t ) { return '> ' } 790 837 my $pr = $self->promptPrefix; 791 838 return sprintf(
Note: See TracChangeset
for help on using the changeset viewer.