From 4608cf7d6cfd7339e1b3211359f5793868ee4d0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu>
Date: Thu, 14 Dec 2017 10:47:23 +0100
Subject: [PATCH] Added `--version` CLI option to show the version of Flamenco
 Worker

---
 CHANGELOG.md           | 1 +
 flamenco_worker/cli.py | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b90e057d..a92bc920 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ changed functionality, fixed bugs).
   This is only supported on POSIX platforms that have those signals.
 - Worker can be told to shut down by the Manager. The environment (for example systemd
   on Linux) is responsible for restarting Flamenco Worker after such a shutdown.
+- Added `--version` CLI option to show the version of Flamenco Worker and quit.
 
 
 ## Version 2.0.8 (released 2017-09-07)
diff --git a/flamenco_worker/cli.py b/flamenco_worker/cli.py
index 4705a991..d86f7734 100644
--- a/flamenco_worker/cli.py
+++ b/flamenco_worker/cli.py
@@ -17,6 +17,8 @@ def main():
     parser.add_argument('-v', '--verbose', action='store_true',
                         help='Show configuration before starting, '
                              'and asyncio task status at shutdown.')
+    parser.add_argument('-V', '--version', action='store_true',
+                        help='Show the version of Flamenco Worker and stops.')
     parser.add_argument('-r', '--reregister', action='store_true',
                         help="Erases authentication information and re-registers this worker "
                              "at the Manager. WARNING: this can cause duplicate worker information "
@@ -27,6 +29,11 @@ def main():
                              "for more powerful options.")
     args = parser.parse_args()
 
+    if args.version:
+        from . import __version__
+        print(__version__)
+        raise SystemExit()
+
     # Load configuration
     from . import config
     confparser = config.load_config(args.config, args.verbose)
-- 
GitLab