Add --version switch to all scripts.
authorMarko Kreen <markokr@gmail.com>
Thu, 1 Oct 2009 11:33:19 +0000 (11:33 +0000)
committerMarko Kreen <markokr@gmail.com>
Thu, 1 Oct 2009 11:33:19 +0000 (11:33 +0000)
Based on patch by Hannu Krosing

Makefile
config.mak.in
python/skytools/__init__.py
python/skytools/installer_config.py.in
python/skytools/scripting.py
python/walmgr.py

index 85031cda28f4f132f586f14be1d45e02ae27ea7d..fbc20e32fb615c7dd55f1fff54559f65292a3f10 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,7 @@ python-install: config.mak modules-all
 
 python-install python-all: python/skytools/installer_config.py
 python/skytools/installer_config.py: python/skytools/installer_config.py.in config.mak
-       sed -e 's!@SQLDIR@!$(SQLDIR)!g' $< > $@
+       sed -e 's!@SQLDIR@!$(SQLDIR)!g' -e 's!@PACKAGE_VERSION@!$(PACKAGE_VERSION)!g' $< > $@
 
 realclean:
        $(MAKE) -C doc $@
index 66edf6c268109e81cdfb211ddc28889b4857b989..77dda1de85832c4b3099d39a6cc6ea371eda6093 100644 (file)
@@ -18,3 +18,8 @@ DESTDIR = /
 ASCIIDOC = @ASCIIDOC@
 XMLTO = @XMLTO@
 
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_STRING = @PACKAGE_STRING@
+
index dc71872b6818dcaca6995dda800a3599dceecee3..e7d25122d79de864d87070f2f03ec46cdfde53af 100644 (file)
@@ -28,3 +28,6 @@ __all__ = (skytools.psycopgwrapper.__all__
         + skytools.quoting.__all__
         + skytools.parsing.__all__)
 
+import skytools.installer_config
+__version__ = skytools.installer_config.package_version
+
index 06c9b9560ef531711246188ea0bc393037406e24..052e215ee94b5032011aeb68a6a59b702471d12e 100644 (file)
@@ -2,3 +2,6 @@
 sql_locations = [
     "@SQLDIR@",
 ]
+
+package_version = "@PACKAGE_VERSION@"
+
index 58f209718824bcf17adc71bc864d1d5a7b6382b5..38739820f28f556f33bcdfe2d588b5f27d6df52a 100644 (file)
@@ -279,6 +279,9 @@ class DBScript(object):
         self.options, self.args = parser.parse_args(args)
 
         # check args
+        if self.options.version:
+            print 'Skytools version', skytools.__version__
+            sys.exit(0)
         if self.options.daemon:
             self.go_daemon = 1
         if self.options.quiet:
@@ -332,6 +335,8 @@ class DBScript(object):
                      help = "make program verbose")
         p.add_option("-d", "--daemon", action="store_true",
                      help = "go background")
+        p.add_option("-V", "--version", action="store_true",
+                     help = "print version info and exit")
 
         # control options
         g = optparse.OptionGroup(p, 'control running process')
index a77993dec7284cbf286bd7a2c9411fd014fda479..8cf8c27369c6897da10bc17da54cd3f103dab1c3 100755 (executable)
@@ -243,6 +243,9 @@ class WalMgr(skytools.DBScript):
 
     def __init__(self, args):
 
+        if len(args) == 1 and args[0] == '--version':
+            skytools.DBScript.__init__(self, 'wal-master', args)
+
         if len(args) < 2:
             # need at least config file and command
             usage(1)