1 package DX::ShellState;
3 use DX::Utils qw(deparse);
6 has template_query_state => (
7 is => 'ro', required => 1, isa => QueryState
10 has current_query_state => (
11 is => 'lazy', builder => 'new_query_state', isa => QueryState
15 is => 'ro', required => 1, isa => HashRef[Str],
18 has mode => (is => 'ro', required => 1, isa => ShellMode);
20 sub new_query_state { $_[0]->template_query_state }
25 my ($tag, $thing) = @_;
26 my ($part) = split /\./, $tag;
27 my $traces = $self->trace_these;
28 return unless $traces->{$part} or $traces->{'*'} or $ENV{DX_TRACE};
29 my $dp = deparse($thing);
35 sub with_trace_changes {
36 my ($self, @changes) = @_;
37 my %trace = %{$self->trace_these};
38 foreach my $change (@changes) {
39 if ($change =~ /^\+?(\S+)/) {
41 } elsif ($change =~ /^-(\S+)/) {
45 return $self->but(trace_these => \%trace);
48 sub with_new_query_state {
51 current_query_state => $self->new_query_state
56 my ($self, $new_mode) = @_;
58 $self->but(mode => $new_mode),
59 [ mode => $new_mode ],