瀏覽代碼

feat: add --version and -v option to print Taipy version

trgiangdo 2 年之前
父節點
當前提交
3298e1bfdd
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      src/taipy/_entrypoint.py

+ 7 - 0
src/taipy/_entrypoint.py

@@ -17,12 +17,19 @@ from taipy.core._version._cli._version_cli import _VersionCLI
 
 from ._cli._help_cli import _HelpCLI
 from ._cli._scaffold_cli import _ScaffoldCLI
+from .version import _get_version
 
 
 def _entrypoint():
     # Add the current working directory to path to execute version command on FS repo
     sys.path.append(os.path.normpath(os.getcwd()))
 
+    _CLI._parser.add_argument("-v", "--version", action="store_true", help="Print the current Taipy version and exit.")
+    args = _CLI._parse()
+    if args.version:
+        print(f"Taipy {_get_version()}")
+        sys.exit(0)
+
     _VersionCLI.create_parser()
     _ScaffoldCLI.create_parser()
     _HelpCLI.create_parser()