| 1 | # -*- coding: utf-8 -*- | ||
| 2 | # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org> | ||
| 3 | use warnings; no warnings 'redefine'; no warnings 'once'; | ||
| 4 | use rlib '../../../../..'; | ||
| 5 | |||
| 6 | package Devel::Trepan::CmdProcessor::Command::Show::Interactive; | ||
| 7 | |||
| 8 | use Devel::Trepan::CmdProcessor::Command::Subcmd::Core; | ||
| 9 | |||
| 10 | @ISA = qw(Devel::Trepan::CmdProcessor::Command::ShowBoolSubcmd); | ||
| 11 | # Values inherited from parent | ||
| 12 | use vars @Devel::Trepan::CmdProcessor::Command::Subcmd::SUBCMD_VARS; | ||
| 13 | |||
| 14 | =pod | ||
| 15 | |||
| 16 | =head2 Synopsis: | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | our $HELP = <<"EOH"; | ||
| 21 | =pod | ||
| 22 | |||
| 23 | B<show interactive> | ||
| 24 | |||
| 25 | Show whether debugger input is a terminal. | ||
| 26 | =cut | ||
| 27 | EOH | ||
| 28 | our $SHORT_HELP = "Show whether debugger input is a terminal"; | ||
| 29 | our $MIN_ABBREV = length('inter'); | ||
| 30 | |||
| 31 | sub run($$) | ||
| 32 | { | ||
| 33 | my ($self, $args) = @_; | ||
| 34 | my $proc = $self->{proc}; | ||
| 35 | my $intf = $proc->{interfaces}->[-1]; | ||
| 36 | my $bool = $intf->is_interactive(); | ||
| 37 | my $msg = sprintf("Debugger's interactive mode is %s.", | ||
| 38 | $self->show_onoff($bool)); | ||
| 39 | $proc->msg($msg); | ||
| 40 | if ($bool) { | ||
| 41 | $bool = $intf->{input}->can("have_term_readline") && | ||
| 42 | $intf->{input}->have_term_readline(); | ||
| 43 | $msg = sprintf("Terminal Readline capability is %s.", | ||
| 44 | $self->show_onoff(!!$bool)); | ||
| 45 | $proc->msg($msg); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | unless (caller) { | ||
| 50 | # Demo it. | ||
| 51 | # require_relative '../../mock' | ||
| 52 | |||
| 53 | # # FIXME: DRY the below code | ||
| 54 | # my ($dbgr, $cmd) = MockDebugger::setup('show'); | ||
| 55 | # $subcommand = __PACKAGE__->new(cmd); | ||
| 56 | # $testcmdMgr = Trepan::Subcmd->new(subcommand); | ||
| 57 | |||
| 58 | # $subcommand->run_show_bool(); | ||
| 59 | # $subcommand->summary_help($NAME); | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; |