aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgit
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cgitize/main.py3
-rw-r--r--cgitize/version.py10
2 files changed, 13 insertions, 0 deletions
diff --git a/cgitize/main.py b/cgitize/main.py
index e787861..879e07d 100644
--- a/cgitize/main.py
+++ b/cgitize/main.py
@@ -10,6 +10,7 @@ import sys
from cgitize.cgit import CGitRepositories, CGitServer
from cgitize.config import Config
from cgitize.utils import setup_logging
+from cgitize.version import __version__
def parse_args(argv=None):
@@ -26,6 +27,8 @@ def parse_args(argv=None):
help='overwrite existing repositories')
parser.add_argument('--verbose', '-v', action='store_true',
help='verbose log output')
+ parser.add_argument('--version', '-V', action='version',
+ version=f'%(prog)s {__version__}')
return parser.parse_args(argv)
diff --git a/cgitize/version.py b/cgitize/version.py
new file mode 100644
index 0000000..5543f34
--- /dev/null
+++ b/cgitize/version.py
@@ -0,0 +1,10 @@
+try:
+ import importlib.metadata as metadata
+except ImportError:
+ import importlib_metadata as metadata
+
+
+try:
+ __version__ = metadata.version('cgitize')
+except Exception:
+ __version__ = 'unknown'