package ::Text::OuterShell; use base qw(Term::Shell); #create_help_subs(); sub catch_run { # my ($o, $cmd, @args) = @_; my $original_command_line = join " ", $cmd, @args; #print "foudn $0 $original_command_line\n"; ::Text::command_process( $original_command_line ); } sub catch_help { my ($o, $cmd, @args) = @_; $debug and print "cmd: $cmd\n"; #my $main_name = # print grep{ $_ eq $cmd } join " ", my $main_name; CMD: for my $k ( keys %commands ){ for my $alias ( $k, split " ",$commands{$k}{short} ){ if ($cmd eq $alias){ $main_name = $k; last CMD; } } } $debug and print "main_name: $main_name\n";
my $txt = $o->help($main_name, @_);
if ($o->{command}{help}{found}) {
$o->page("$txt\n")
}
}
#my $print "catched help @_"} sub prompt_str { 'Enter command: ' } sub run_help { my $o = shift; my $cmd = shift; if ($cmd) { my $txt = $o->help($cmd, @_); if ($o->{command}{help}{found}) { $o->page("$txt\n") } else { my @c = sort $o->possible_actions($cmd, 'help'); if (@c and $o->{API}{match_uniq}) { local $" = "\n\t"; print <<END; Ambiguous help topic '$cmd': possible help topics: @c END } else { print <<END; Unknown help topic '$cmd'; type 'help' for a list of help topics. END } } } else { print "Type 'help command' for more detailed help on a command.\n"; my $help_screen = <<HELP; Help Screen Goes here HELP $o->page($help_screen); } }
sub create_help_subs { $debug2 and print "create_help_subs\n"; %commands = %{ ::yaml_in( $::commands_yml) };
$debug and print ::yaml_out \%commands;
map{ print $_, $/} grep{ $_ !~ /mark/ and $_ !~ /effect/ } keys %commands;
map{
my $run_code = qq!sub run_$_ { splice \@_,1,0, q($_); catch_run( \@_) }; !;
$debug and print "evalcode: $run_code\n";
eval $run_code;
$debug and $@ and print "create_sub eval error: $@\n";
my $help_code = qq!sub help_$_ { q($commands{$_}{what}) };!;
$debug and print "evalcode: $help_code\n";
eval $help_code;
$debug and $@ and print "create_sub eval error: $@\n";
my $smry_text =
$commands{$_}{smry} ? $commands{$_}{smry} : $commands{$_}{what};
$smry_text .= qq! ($commands{$_}{short}) !
if $commands{$_}{short};
my $smry_code = qq!sub smry_$_ { q( $smry_text ) }; !;
$debug and print "evalcode: $smry_code\n";
eval $smry_code;
$debug and $@ and print "create_sub eval error: $@\n";
my $alias_code = qq!sub alias_$_ { qw($commands{$_}{short}) }; !;
$debug and print "evalcode: $alias_code\n";
eval $alias_code;# noisy in docs
$debug and $@ and print "create_sub eval error: $@\n";
}
grep{ $_ !~ /mark/ and $_ !~ /effect/ } keys %commands;
}
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 190:
Unknown directive: =comment