« blib/lib/Devel/Trepan/Deparse.pm
↑ Summary
blib/lib/Devel/Trepan/CmdProcessor/Command/Show_Subcmd/Auto_Subcmd/Deparse.pm »
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | # Copyright (C) 2015 Rocky Bernstein <rocky@cpan.org> | ||
| 3 | use warnings; no warnings 'redefine'; no warnings 'once'; | ||
| 4 | |||
| 5 | use Devel::Trepan::CmdProcessor::Command::Subcmd::Subsubcmd; | ||
| 6 | |||
| 7 | package Devel::Trepan::CmdProcessor::Command::Set::Auto::Deparse; | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use vars qw(@ISA @SUBCMD_VARS); | ||
| 11 | @ISA = qw(Devel::Trepan::CmdProcessor::Command::SetBoolSubsubcmd); | ||
| 12 | # Values inherited from parent | ||
| 13 | |||
| 14 | use vars @Devel::Trepan::CmdProcessor::Command::Subsubcmd::SUBCMD_VARS; | ||
| 15 | |||
| 16 | our $IN_LIST = 1; | ||
| 17 | our $HELP = <<'HELP'; | ||
| 18 | =pod | ||
| 19 | |||
| 20 | B<set auto deparse> [B<on>|B<off>] | ||
| 21 | |||
| 22 | Set to run a C<deparse> when there is an ambiguity in line number. | ||
| 23 | |||
| 24 | =head2 See also: | ||
| 25 | |||
| 26 | L<C<show auto deparse>|Devel::Trepan::CmdProcessor::Command::Show::Auto::List> | ||
| 27 | |||
| 28 | =cut | ||
| 29 | HELP | ||
| 30 | |||
| 31 | our $MIN_ABBREV = length('de'); | ||
| 32 | use constant MAX_ARGS => 1; | ||
| 33 | our $SHORT_HELP = "show deparse output on line ambiguity"; | ||
| 34 | |||
| 35 | sub new | ||
| 36 | { | ||
| 37 | my ($class, $parent, $name) = @_; | ||
| 38 | my $self = Devel::Trepan::CmdProcessor::Command::Subsubcmd::new($class, $parent, $name); | ||
| 39 | bless $self, $class; | ||
| 40 | my $deparse_cmd = $self->{proc}{commands}{'deparse'}; | ||
| 41 | $self->{autodeparse_hook} = ['autodeparse', | ||
| 42 | sub{ $deparse_cmd->run(['deparse']) if $deparse_cmd}]; | ||
| 43 | return $self | ||
| 44 | } | ||
| 45 | |||
| 46 | sub run($$) | ||
| 47 | { | ||
| 48 | my ($self, $args) = @_; | ||
| 49 | $self->SUPER::run($args); | ||
| 50 | my $proc = $self->{proc}; | ||
| 51 | if ( $proc->{settings}{autodeparse} ) { | ||
| 52 | $proc->{cmdloop_prehooks}->insert_if_new(10, $self->{autodeparse_hook}[0], | ||
| 53 | $self->{autodeparse_hook}[1]); | ||
| 54 | } else { | ||
| 55 | $proc->{cmdloop_prehooks}->delete_by_name('autodeparse'); | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | } | ||
| 60 | |||
| 61 | unless (caller) { | ||
| 62 | # Demo it. | ||
| 63 | # require_relative '../../../mock' | ||
| 64 | # name = File.basename(__FILE__, '.rb') | ||
| 65 | |||
| 66 | # dbgr, set_cmd = MockDebugger::setup('set') | ||
| 67 | # max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.core.processor, | ||
| 68 | # set_cmd) | ||
| 69 | # cmd_ary = Trepan::SubSubcommand::SetMaxList::PREFIX | ||
| 70 | # cmd_name = cmd_ary.join(' ') | ||
| 71 | # subcmd = Trepan::SubSubcommand::SetMaxList.new(set_cmd.proc, | ||
| 72 | # max_cmd, | ||
| 73 | # cmd_name) | ||
| 74 | # prefix_run = cmd_ary[1..-1] | ||
| 75 | # subcmd.run(prefix_run) | ||
| 76 | # subcmd.run(prefix_run + %w(0)) | ||
| 77 | # subcmd.run(prefix_run + %w(20)) | ||
| 78 | # name = File.basename(__FILE__, '.rb') | ||
| 79 | # subcmd.summary_help(name) | ||
| 80 | # puts | ||
| 81 | # puts '-' * 20 | ||
| 82 | # puts subcmd.save_command | ||
| 83 | } | ||
| 84 | |||
| 85 | 1; |