summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-08-23 15:14:18 +0200
committerGuido Günther <agx@sigxcpu.org>2014-08-23 15:28:56 +0200
commit5f82f445abbab55a6b2ad8d82b8ddf21eff69628 (patch)
tree56008e5df087e34ac5ec6c8666c368317239134a
parentae5805e4db74e844f78777c2fd91f409e0fcd7a8 (diff)
downloadgit-buildpackage-5f82f445abbab55a6b2ad8d82b8ddf21eff69628.tar.gz
git-buildpackage-5f82f445abbab55a6b2ad8d82b8ddf21eff69628.tar.bz2
git-buildpackage-5f82f445abbab55a6b2ad8d82b8ddf21eff69628.zip
gbp: add --version option
Closes: #758909
-rw-r--r--gbp/scripts/supercommand.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/gbp/scripts/supercommand.py b/gbp/scripts/supercommand.py
index 2eb64de2..e529b38c 100644
--- a/gbp/scripts/supercommand.py
+++ b/gbp/scripts/supercommand.py
@@ -17,6 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Supercommand for all gbp commands"""
+import os
import re
import sys
@@ -44,6 +45,13 @@ The most commonly used commands are:
import-dscs - import multiple Debian source packages
"""
+def version(prog):
+ try:
+ from gbp.version import gbp_version
+ except ImportError:
+ gbp_version = '[Unknown version]'
+ print("%s %s" % (os.path.basename(prog), gbp_version))
+
def import_command(cmd):
"""
Import the module that implements the given command
@@ -63,12 +71,15 @@ def supercommand(argv=None):
usage()
return 1
- cmd = argv[1]
+ prg, cmd = argv[0:2]
args = argv[1:]
if cmd in ['--help', '-h']:
usage()
return 0
+ elif cmd in [ '--version', 'version' ]:
+ version(argv[0])
+ return 0
try:
module = import_command(cmd)
@@ -81,4 +92,7 @@ def supercommand(argv=None):
return module.main(args)
+if __name__ == '__main__':
+ sys.exit(supercommand())
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: