package Psh
::Builtins
::Strategy
;
=item * C<strategy list> shows the list of currently used strategies
=item * C<strategy available> shows the list of available strategies
=item * C<strategy add "name"> adds a strategy before the consume-all eval strategy
=item * C<strategy add "name" before "name"> inserts a strategy before the other one
=item * C<strategy add "name" after "name"> inserts a strategy after the other one
=item * C<strategy del "name"> removes a strategy
=item * C<strategy help "name"> shows help about a strategy
require Psh
::Builtins
::Help
;
Psh
::Builtins
::Help
::bi_help
('strategy');
} elsif( $words->[0] eq 'add') {
my $strat= lc($words->[1]);
my $obj= Psh
::Strategy
::get
($strat);
Psh
::Util
::print_error_i18n
('bi_strategy_notfound',$strat);
$pos= Psh
::Strategy
::find
($pos);
Psh
::Util
::print_error_i18n
('bi_strategy_notfound',$words->[3]);
if( $words->[2] eq 'after') {
Psh
::Strategy
::add
($obj,$pos) if $obj;
} elsif( $words->[0] eq 'del' ||
$words->[0] eq 'remove') {
Psh
::Strategy
::remove
($words->[1]);
} elsif( $words->[0] eq 'show' ||
Psh
::Util
::print_out_i18n
('bi_strategy_list');
my @list= Psh
::Strategy
::list
();
for( my $i=0; $i<@list; $i++) {
Psh
::Util
::print_out
(($i+1).") ".$list[$i]->name.
($list[$i]->consumes == Psh
::Strategy
::CONSUME_LINE
()?
' (line)':'').
} elsif( $words->[0] eq 'help') {
require Psh
::Builtins
::Help
;
Psh
::Builtins
::Help
::bi_help
('strategy');
foreach my $line (@INC) {
my $tmpfile= Psh
::OS
::catfile
(
Psh
::OS
::catdir
($line,'Psh','Strategy'),
ucfirst($words->[1]).'.pm');
$tmp= Psh
::Builtins
::Help
::get_pod_from_file
($tmpfile,
Psh
::OS
::display_pod
("=over 4\n".$tmp."\n=back\n");
} elsif( $words->[0] eq 'available') {
my @list= Psh
::Strategy
::available_list
();
Psh
::Util
::print_list
(@list);
Psh
::Util
::print_error_i18n
('bi_strategy_wrong_arg');
my( $text, $dummy, $starttext) = @_;
my @words= split ' ',$starttext;
$Psh::Completion
::ac
=' ';
return (1,grep { Psh
::Util
::starts_with
($_,$text) }
return (1,grep { Psh
::Util
::starts_with
($_,$text) }
if( $words[1] eq 'del' || $words[1] eq 'remove') {
return (1,grep { Psh
::Util
::starts_with
($_,$text) }
} elsif( $words[1] eq 'help' || $words[1] eq 'add') {
return (1, grep { Psh
::Util
::starts_with
($_,$text) }
_generate_strategy_list
());
return (1,grep { Psh
::Util
::starts_with
($_,$text) }
qw(show list del help remove add available));