From 9d3c366a26dab1e00a413368da1582fb7f0abf6b Mon Sep 17 00:00:00 2001 From: John van de Wetering Date: Tue, 28 Aug 2018 13:55:06 +0200 Subject: [PATCH] Made Quantomatic accept commandline arguments (See #202). The first argument, if given, should point to a project file to be opened. The second argument, if given, should point to a qgraph/qrule/etc file to be opened. Used to interact with github.com/Quantomatic/pyzx --- .../src/main/scala/quanto/gui/QuantoDerive.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scala/src/main/scala/quanto/gui/QuantoDerive.scala b/scala/src/main/scala/quanto/gui/QuantoDerive.scala index dc71d3c9..3ccf26e7 100644 --- a/scala/src/main/scala/quanto/gui/QuantoDerive.scala +++ b/scala/src/main/scala/quanto/gui/QuantoDerive.scala @@ -34,12 +34,27 @@ import java.lang.NullPointerException import javax.imageio.ImageIO import javax.swing.filechooser.FileNameExtensionFilter import quanto.gui.QuantoDerive.FileMenu.mnemonic +import quanto.gui.FileOpened import quanto.util._ class NoProjectException extends Exception("No project open.") object QuantoDerive extends SimpleSwingApplication { + override def main(args: Array[String]): Unit = { + super.main(args) + if (args.length > 0) { + alert("Loading project from commandline") + val arg = args(0) + loadProject(arg) + } + if (args.length > 1) { + alert("Opening file from commandline") + val fname = args(1) + ProjectFileTree.publish(FileOpened(new File(fname))) + } + } + System.setProperty("apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS") val CommandMask = java.awt.Toolkit.getDefaultToolkit.getMenuShortcutKeyMask val actorSystem = ActorSystem("QuantoDerive")