Browse Source

add argparse with --version option

Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Doug Hellmann 1 year ago
parent
commit
eb61124102
1 changed files with 15 additions and 1 deletions
  1. 15
    1
      git_nit/cmd.py

+ 15
- 1
git_nit/cmd.py View File

@@ -14,9 +14,23 @@
14 14
 
15 15
 from __future__ import print_function
16 16
 
17
+import argparse
18
+import pkg_resources
19
+def get_version():
20
+    requirement = pkg_resources.Requirement.parse('git-nit')
21
+    provider = pkg_resources.get_provider(requirement)
22
+    return provider.version
23
+
24
+
17 25
 
18 26
 def main():
19
-    pass
27
+    parser = argparse.ArgumentParser()
28
+    parser.add_argument(
29
+        '--version',
30
+        action='version',
31
+        version=get_version(),
32
+    )
33
+    args = parser.parse_args()
20 34
 
21 35
 
22 36
 if __name__ == '__main__':

Loading…
Cancel
Save