10 my $solver = DX::Solver->new(observation_policy => sub { 1 });
12 DX::Lib::FS->new->load_into($solver);
15 # [ $solver->query([ 'D' ], [ directory_at => 'D' => \'t' ])->results ]
16 # ->[0]->value_for('D')
23 my $split = $tcl->curry::weak::SplitList;
28 @res = $solver->query(@last_q)->results;
30 my @act = $_->actions;
31 ((@act ? \@act : ()), $_->all_values);
36 my ($vars, $body) = @_;
37 my @varnames = $split->($vars);
38 return (\@varnames, expand_body($body));
43 local our @Body_Parts;
48 $tcl->CreateCommand(query => sub {
49 my (undef, undef, undef, $vars, $body) = @_;
50 @last_q = expand_def($vars, $body);
55 $tcl->CreateCommand(run => sub {
56 foreach my $ind ($res[0]->independent_actions) {
58 warn +(split('::', $cl))[-1]."\n";
59 $solver->run_action($ind);
67 map { $_ =~ /^'(.*)'$/ ? \do { my $x = $1 } : $_ } @args;
71 my (undef, undef, $name, @args) = @_;
72 push our @Body_Parts, [ $name => mangle_args(@args) ];
76 $tcl->CreateCommand(rule => sub {
77 my (undef, undef, undef, $rule, $vars, $body) = @_;
78 $solver->add_rule($rule => expand_def($vars, $body));
79 $tcl->CreateCommand($rule => $rule_sub);
83 foreach my $rule (keys %{$solver->rule_set->rules}) {
85 $tcl->CreateCommand($rule => $rule_sub);
88 $tcl->CreateCommand(exists => sub {
89 my (undef, undef, undef, $vars, $body) = @_;
90 push our @Body_Parts, [ exists => expand_def($vars, $body) ];
94 $tcl->CreateCommand(foreach => sub {
95 my (undef, undef, undef, $var, $body, $each_body) = @_;
96 push our @Body_Parts, [
97 foreach => $var => map [ expand_body($_) ], $body, $each_body
102 #$tcl->Eval(q{query D {directory_at D 't'; mode D '0755'; }});
105 $tcl->EvalFile($ARGV[0]);
108 my $rl = Term::ReadLine->new;
112 while (defined(my $line = $rl->readline(length($cmd)?'> ':'$ '))) {
114 if ($tcl->call(info => complete => $cmd)) {
115 unless (eval { $tcl->Eval($cmd); 1 }) {