File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change
1
+ Allow `tools ` to report it's version
Original file line number Diff line number Diff line change 28
28
from ptscripts import logs
29
29
from ptscripts import process
30
30
31
+ try :
32
+ import importlib .metadata
33
+
34
+ __version__ = importlib .metadata .version ("python-tools-scripts" )
35
+ except ImportError :
36
+ import importlib_metadata
37
+
38
+ __version__ = importlib_metadata .version ("python-tools-scripts" )
39
+
31
40
if TYPE_CHECKING :
32
41
from argparse import ArgumentParser
33
42
from argparse import _SubParsersAction
@@ -192,6 +201,7 @@ def __new__(cls):
192
201
epilog = "These tools are discovered under `<repo-root>/tools`." ,
193
202
allow_abbrev = False ,
194
203
)
204
+ instance .parser .add_argument ("--version" , action = "version" , version = __version__ )
195
205
log_group = instance .parser .add_argument_group ("Logging" )
196
206
timestamp_meg = log_group .add_mutually_exclusive_group ()
197
207
timestamp_meg .add_argument (
You can’t perform that action at this time.
0 commit comments