diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java index 38299e705..bd8d4056f 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java @@ -38,6 +38,7 @@ import org.graphwalker.cli.util.LoggerUtil; import org.graphwalker.cli.util.UnsupportedFileFormat; import org.graphwalker.core.event.EventType; +import org.graphwalker.core.generator.SingletonRandomGenerator; import org.graphwalker.core.machine.Context; import org.graphwalker.core.machine.MachineException; import org.graphwalker.core.machine.SimpleMachine; @@ -452,11 +453,20 @@ private void runCommandOffline() throws Exception, UnsupportedFileFormat { System.out.println(Util.getStepAsJSON(machine, offline.verbose, offline.unvisited).toString()); } }); + + if (offline.seed != 0) { + SingletonRandomGenerator.setSeed(offline.seed); + } + executor.execute(); } else if (!offline.gw3.isEmpty()) { //TODO Fix gw3. Should not be there List contexts = new JsonContextFactory().create(Paths.get(offline.gw3)); + if (offline.seed != 0) { + SingletonRandomGenerator.setSeed(offline.seed); + } + if (offline.blocked) { org.graphwalker.io.common.Util.filterBlockedElements(contexts); } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java index c64f568bf..e6f0d1374 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java @@ -58,4 +58,8 @@ public class Offline { @Parameter(names = {"--blocked", "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") public boolean blocked = true; + + @Parameter(names = {"--seed", "-d"}, required = false, + description = "Seed the random generator using the provided number.") + public long seed = 0; }