1 package DX::ShellFrontend;
8 is => 'ro', required => 1,
9 handles => [ qw(is_complete_command_string eval_command_string) ]
12 has session_mode => (is => 'rwp', required => 1);
14 has readline => (is => 'lazy', builder => sub { Caroline->new });
16 sub BUILD { STDOUT->autoflush(1) }
21 last unless $self->rep
27 return unless defined(my $command = $self->read_command);
28 my @result = $self->eval_command_string($command);
29 $self->process_result(@result);
35 my $base_prompt = $self->session_mode eq 'shell' ? '$ ' : '? ';
36 my $rl = $self->readline;
37 return unless defined(my $command = $rl->readline($base_prompt));
38 while (not $self->is_complete_command_string($command)) {
39 $command .= $rl->readline('> ');
41 $rl->history_add($command);
46 my ($self, @result) = @_;
47 foreach my $res (@result) {
48 my ($type, $payload) = @$res;
49 $self->${\($self->can("process_${type}_result")||die)}($payload);
53 sub process_mode_result {
54 my ($self, $mode) = @_;
55 $self->_set_session_mode($mode);
58 sub process_output_result {
59 my ($self, $output) = @_;