From: Guido Günther Date: Sat, 23 Aug 2014 13:14:18 +0000 (+0200) Subject: gbp: add --version option X-Git-Tag: debian/0.6.17~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f82f445abbab55a6b2ad8d82b8ddf21eff69628;p=tools%2Fgit-buildpackage.git gbp: add --version option Closes: #758909 --- diff --git a/gbp/scripts/supercommand.py b/gbp/scripts/supercommand.py index 2eb64de..e529b38 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\:·: