Jeff-Ciesielski / Boms-Away

Component/BOM management tool for KiCad
GNU General Public License v3.0
93 stars 20 forks source link

Supply schematic file on command line #27

Open ghost opened 6 years ago

ghost commented 6 years ago

I've hacked bomsaway to take a filename on the command line so I can run it direct from KiCAD with the command:

python "/full/path/to/Boms-Away/bomsaway.py" "%P/%B.sch" &

Or just supply the filename on the command line in the normal way, or not.

Hoping this is useful.

Here's the diff:

diff --git bomsaway.py bomsaway.py
index ec09d86..2966997 100755
--- bomsaway.py
+++ bomsaway.py
@@ -2,6 +2,7 @@
 import os
 import csv
 import shutil
+import sys

 import wx
 from boms_away import sch, datastore
@@ -581,9 +582,15 @@ class MainFrame(wx.Frame):

 class BomsAwayApp(wx.App):
     def OnInit(self):
+        ifile = None
+        try:
+            ifile = sys.argv[1]
+        except:
+            pass
         frame = MainFrame(None, -1, 'Boms-Away!')
         frame.Show(True)
         self.SetTopWindow(frame)
+        if ifile: frame.load(ifile)
         return True

 if __name__ == '__main__':
Jeff-Ciesielski commented 6 years ago

Good idea, I'll fold this in ASAP