]> hydra-www.ietfng.org Git - dyna2/commitdiff
Issue #62: allow Dyna to report its own version.
authorTim Vieira <tim.f.vieira@gmail.com>
Tue, 23 Jul 2013 07:24:59 +0000 (03:24 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Tue, 23 Jul 2013 07:24:59 +0000 (03:24 -0400)
src/Dyna/Backend/Python/main.py

index 37a80b087560712cbcbcb1e1514249b82230127a..940a2cbc0c4ac472e2aaba71564b37c3e97c7700 100644 (file)
@@ -4,11 +4,14 @@ from errors import DynaCompilerError
 from errors import crash_handler
 from interpreter import Interpreter
 from repl import REPL
-from config import dotdynadir
+from config import dotdynadir, dynahome
 import post, load
 
 def main():
     parser = argparse.ArgumentParser(description="The dyna interpreter!")
+
+    parser.add_argument('--version', action='store_true',
+                        help='Print version information.')
     parser.add_argument('source', nargs='*', type=path,
                         help='Path to Dyna source file.')
     parser.add_argument('-i', dest='interactive', action='store_true',
@@ -23,6 +26,16 @@ def main():
 
     args = parser.parse_args()
 
+    if args.version:
+        import subprocess
+        try:
+            subprocess.Popen("cd %s ; grep '^Version' dyna.cabal" % dynahome, shell=True)
+            subprocess.Popen("cd %s ; git log -n 1 |grep '^Date' " % dynahome, shell=True)
+            subprocess.Popen("cd %s ; git log -n 1 |grep '^commit' " % dynahome, shell=True)
+        except OSError:
+            print 'failed to obtain version info.'
+        exit(0)
+
     interp = Interpreter()
 
     crash_handler()