From 88e0ef65c89a96051a55da174a36c4a55328ecaa Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Tue, 14 Jan 2025 17:17:11 +0100 Subject: [PATCH] Fix running the evaluator from the CLI. --- .../java/org/alloytools/alloy/cli/CLI.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/org.alloytools.alloy.cli/src/main/java/org/alloytools/alloy/cli/CLI.java b/org.alloytools.alloy.cli/src/main/java/org/alloytools/alloy/cli/CLI.java index 8c533bc68..40905b7ba 100644 --- a/org.alloytools.alloy.cli/src/main/java/org/alloytools/alloy/cli/CLI.java +++ b/org.alloytools.alloy.cli/src/main/java/org/alloytools/alloy/cli/CLI.java @@ -204,7 +204,6 @@ public void _exec(ExecOptions options) throws Exception { } } OutputTrace trace = new OutputTrace(quiet || outdir == null ? null : stderr); - Map answers = new TreeMap<>(); int n = 0; int repeat = options.repeat(1); @@ -281,9 +280,8 @@ public void _exec(ExecOptions options) throws Exception { trace.format(" expects=%s", c.expects); error("'%s' was satisfied against expectation",c); } - - if (options.evaluator() && !answers.isEmpty()) { - evaluator(world, answers); + if (options.evaluator()) { + evaluator(world, solution); } } n++; @@ -358,19 +356,15 @@ private String getStem(File file) { return parts[0]; } - private void evaluator(CompModule world, Map answers) throws Exception { - for (Entry s : answers.entrySet()) { - A4Solution sol = s.getValue(); - if (sol.satisfiable()) { - stdout.println("Evaluator for " + s.getKey().command); - stdout.flush(); - Evaluator e = new Evaluator(world, sol, stdin, stdout); - String lastCommand = e.loop(); - if (lastCommand.equals("/exit")) - break; - } + private void evaluator(CompModule world, A4Solution sol) throws Exception { + if (sol.satisfiable()) { + stdout.println("Evaluator for latest command"); + stdout.flush(); + Evaluator e = new Evaluator(world, sol, stdin, stdout); + String lastCommand = e.loop(); + if (lastCommand.equals("/exit")) + return; } - stdout.println("bye"); } @Arguments(arg = "path")