From 24e77a15b44dab73c2ae83922f8fec67640c7f71 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 20 Sep 2016 19:47:27 +0200 Subject: [PATCH] Add option to print version number, fix issue #90 --- pirate/data.py | 2 ++ pirate/pirate.py | 8 ++++++++ setup.py | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pirate/data.py b/pirate/data.py index e33cb5a..d63de43 100644 --- a/pirate/data.py +++ b/pirate/data.py @@ -5,6 +5,8 @@ import pkgutil def get_resource(filename): return pkgutil.get_data(__package__, 'data/' + filename) +version = '0.2.9' + categories = json.loads(get_resource('categories.json').decode()) sorts = json.loads(get_resource('sorts.json').decode()) blacklist = set(json.loads(get_resource('blacklist.json').decode())) diff --git a/pirate/pirate.py b/pirate/pirate.py index 2e5f971..5f8ed01 100755 --- a/pirate/pirate.py +++ b/pirate/pirate.py @@ -173,6 +173,9 @@ def parse_args(args_in): parser.add_argument('-m', '--mirror', type=str, nargs='+', help='the pirate bay mirror(s) to use') + parser.add_argument('-v', '--version', + action='store_true', + help='print pirate-get version number') args = parser.parse_args(args_in) return args @@ -285,6 +288,11 @@ def search_mirrors(printer, args): def pirate_main(args): printer = Printer(args.color) + # print version + if args.version: + printer.print('pirate-get, version {}'.format(pirate.data.version)) + sys.exit(0) + # check it transmission is running if args.transmission: ret = subprocess.call(args.transmission_command + ['-l'], diff --git a/setup.py b/setup.py index 1ced68e..388e254 100755 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ from setuptools import setup, find_packages from distutils.version import LooseVersion import sys +import pirate.data if LooseVersion(sys.version) < LooseVersion("3.4.0"): print("pirate-get requires at least python 3.4.0." @@ -10,7 +11,7 @@ if LooseVersion(sys.version) < LooseVersion("3.4.0"): if __name__ == '__main__': setup(name='pirate-get', - version='0.2.9', + version=pirate.data.version, description='A command line interface for The Pirate Bay', url='https://github.com/vikstrous/pirate-get', author='vikstrous',