diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-05-03 20:43:33 +0200 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-05-03 20:43:33 +0200 |
| commit | 8d8746e207193862546c1308ecd05415afbbd75a (patch) | |
| tree | 8c09ce152148505fda67c1ed99711cad02d20791 /py3status | |
| parent | 2277bdaf1237195ae8834a5bb3d46333f2d1d8c1 (diff) | |
add --version parameter wrt issue #29
Diffstat (limited to 'py3status')
| -rwxr-xr-x | py3status/__init__.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/py3status/__init__.py b/py3status/__init__.py index fb452bd..e453cda 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -598,6 +598,14 @@ class Py3statusWrapper(): 'interval': 1 } + # package version + try: + import pkg_resources + version = pkg_resources.get_distribution('py3status').version + except: + version = 'unknown' + config['version'] = version + # command line options parser = argparse.ArgumentParser( description='The agile, python-powered, i3status wrapper') @@ -626,8 +634,21 @@ class Py3statusWrapper(): default=config['cache_timeout'], help="""default injection cache timeout in seconds (default 60 sec)""") + parser.add_argument('-v', '--version', action="store_true", + help="""show py3status version and exit""") options = parser.parse_args() + # only asked for version + if options.version: + from platform import python_version + print( + 'py3status version {} (python {})'.format( + config['version'], + python_version() + ) + ) + sys.exit(0) + # override configuration and helper variables config['cache_timeout'] = options.cache_timeout config['debug'] = options.debug |
