basic trace level control from the shell
[scpubgit/DX.git] / lib / DX / ShellSession.pm
index a24a106..fa6cb32 100644 (file)
@@ -31,7 +31,7 @@ has tcl => (is => 'lazy', builder => sub {
   });
   $tcl->CreateCommand('...' => sub {
     $self->apply_to_state([ mode => 'shell' ]);
-    my ($cur) = $self->shell_state->current_query_state;
+    my $orig = my $cur = $self->shell_state->current_query_state;
     while ($cur) {
       $self->_set_shell_state(
         $self->shell_state->but(current_query_state => $cur)
@@ -40,6 +40,12 @@ has tcl => (is => 'lazy', builder => sub {
       $cur = eval { $cur->with_forced_backtrack };
       push our @Result, [ output => $@ ] if $@;
     }
+    $self->_set_shell_state(
+      $self->shell_state->but(
+        current_query_state => $orig
+      ),
+    );
+    return;
   });
   $tcl->CreateCommand(qlist => sub {
     push our @Result, map [ output => $_ ], @{
@@ -87,6 +93,12 @@ has tcl => (is => 'lazy', builder => sub {
       ),
     );
   });
+  $tcl->CreateCommand(trace => sub {
+    my (undef, undef, undef, @trace) = @_;
+    $self->_set_shell_state(
+      $self->shell_state->with_trace_changes(@trace)
+    );
+  });
   return $tcl;
 });