« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Timer.pm
↑ Summary
blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Trace_Subcmd/Print.pm »
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | # Copyright (C) 2012, 2014, 2018 Rocky Bernstein <rocky@cpan.org> | ||
| 3 | use warnings; no warnings 'redefine'; | ||
| 4 | use rlib '../../../../..'; | ||
| 5 | |||
| 6 | package Devel::Trepan::CmdProcessor::Command::Load::Command; | ||
| 7 | use Cwd 'abs_path'; | ||
| 8 | |||
| 9 | # FIXME: allow specifying just the Perl module name, | ||
| 10 | # e.g. File::Basename a command name, e.g. alias. | ||
| 11 | |||
| 12 | use Devel::Trepan::CmdProcessor::Command::Subcmd::Core; | ||
| 13 | |||
| 14 | use strict; | ||
| 15 | our (@ISA, @SUBCMD_VARS); | ||
| 16 | # Values inherited from parent | ||
| 17 | use vars @Devel::Trepan::CmdProcessor::Command::Subcmd::SUBCMD_VARS; | ||
| 18 | |||
| 19 | unless (@ISA) { | ||
| 20 | eval <<"EOE"; | ||
| 21 | use constant MAX_ARGS => undef; # unlimited. | ||
| 22 | EOE | ||
| 23 | } | ||
| 24 | |||
| 25 | @ISA = qw(Devel::Trepan::CmdProcessor::Command::Subcmd); | ||
| 26 | |||
| 27 | =pod | ||
| 28 | |||
| 29 | =head2 Synopsis: | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | our $HELP = <<'HELP'; | ||
| 34 | =pod | ||
| 35 | |||
| 36 | B<load commmand> {I<file-or-directory-name-1> [I<file-or-directory-name-2>...]} | ||
| 37 | |||
| 38 | Load debugger commands or directories containing debugger | ||
| 39 | commands. This is also useful if you want add, change, or fix a debugger | ||
| 40 | command while inside the debugger. | ||
| 41 | =cut | ||
| 42 | HELP | ||
| 43 | |||
| 44 | our $SHORT_HELP = 'Load debugger command(s)'; | ||
| 45 | our $MIN_ABBREV = length('co'); | ||
| 46 | |||
| 47 | sub complete($$) | ||
| 48 | { | ||
| 49 | my ($self, $prefix) = @_; | ||
| 50 | $self->{proc}->filename_complete($prefix); | ||
| 51 | } | ||
| 52 | |||
| 53 | sub run($$) | ||
| 54 | { | ||
| 55 | my ($self, $args) = @_; | ||
| 56 | my $proc = $self->{proc}; | ||
| 57 | my @args = @$args; shift @args; shift @args; | ||
| 58 | foreach my $file_or_dir (@args) { | ||
| 59 | my @errs = $proc->load_debugger_commands($file_or_dir); | ||
| 60 | if(@errs) { | ||
| 61 | $proc->errmsg("Devel::Trepan command $file_or_dir failed"); | ||
| 62 | $proc->errmsg(join("\n", @errs)); | ||
| 63 | } else { | ||
| 64 | $proc->msg("Devel::Trepan command $file_or_dir loaded ok"); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | unless (caller) { | ||
| 70 | require Devel::Trepan; | ||
| 71 | # Demo it. | ||
| 72 | # require_relative '../../mock' | ||
| 73 | # my($dbgr, $parent_cmd) = MockDebugger::setup('show'); | ||
| 74 | # $cmd = __PACKAGE__->new(parent_cmd); | ||
| 75 | # $cmd->run(@$cmd->prefix); | ||
| 76 | } | ||
| 77 | |||
| 78 | # Suppress a "used-once" warning; | ||
| 79 | $HELP || scalar @SUBCMD_VARS; |