diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-03-02 14:28:33 +0100 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-03-02 16:28:39 +0100 |
commit | ed86e96d158600fb4555d23066dec5db822b73ef (patch) | |
tree | 028d576552e10bf5248ab6b8bc1cba5fbcab4960 /cgitize | |
parent | workflows/ci: test w/ Python 3.11 also (diff) | |
download | cgitize-ed86e96d158600fb4555d23066dec5db822b73ef.tar.gz cgitize-ed86e96d158600fb4555d23066dec5db822b73ef.zip |
add runtime version information
Diffstat (limited to 'cgitize')
-rw-r--r-- | cgitize/main.py | 3 | ||||
-rw-r--r-- | cgitize/version.py | 10 |
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' |