1 package DX::ShellSession;
4 use Scalar::Util qw(weaken);
7 has shell_state => (is => 'rwp', required => 1, isa => ShellState);
9 has tcl => (is => 'lazy', builder => sub {
13 $tcl->CreateCommand('?' => sub {
14 $self->apply_to_state([ 'new_query_state' ], [ mode => 'query' ])
16 $tcl->CreateCommand('?+' => sub {
17 $self->apply_to_state([ mode => 'query' ])
19 $tcl->CreateCommand('.' => sub {
20 $self->apply_to_state([ mode => 'shell' ])
26 my ($self, @to_apply) = @_;
27 my $state = $self->shell_state;
29 foreach my $to_apply (@to_apply) {
30 my ($change, @args) = @$to_apply;
31 ($state, my @this_result) = $state->${\"with_${change}"}(@args);
32 push @Result, @this_result;
34 $self->_set_shell_state($state);
38 sub is_complete_command_string {
39 my ($self, $string) = @_;
40 return !!$self->tcl->icall(info => complete => $string);
43 sub eval_command_string {
44 my ($self, $string) = @_;
46 $self->tcl->Eval($string);