Skip to content

Commit 6e7eca8

Browse files
committed
Add support to dump version info (feature request)
Signed-off-by: Ashish Bijlani <ashish.bijlani@gmail.com>
1 parent 64437b6 commit 6e7eca8

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

packj/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.14"

packj/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def main(config:str='.packj.yaml'):
2020
args = opts.args()
2121
assert args, 'Failed to get cmdline args!'
2222

23+
# version request
24+
if args.ver and not args.cmd:
25+
from packj import __version__
26+
print(__version__)
27+
exit(1)
28+
2329
# configuration file
2430
if not os.path.exists(config):
2531
config = os.path.expanduser(os.path.join('~', f'{config}'))

packj/options.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

33
import argparse
4+
from packj import __version__
45

56
class Options():
67
__args = None
@@ -9,10 +10,12 @@ def args(self):
910
return self.__args
1011

1112
def __init__(self, argv):
12-
parser = argparse.ArgumentParser(prog='packj v0.1',
13+
parser = argparse.ArgumentParser(prog=f'packj {__version__}',
1314
usage='main [options] args',
1415
description='Packj flags malicious/risky open-source packages')
15-
subparsers = parser.add_subparsers(title='actions', dest='cmd', help='Command (e.g. audit, sandbox)')
16+
subparsers = parser.add_subparsers(title='actions', dest='cmd', help='Command (e.g. auth, audit, sandbox)')
17+
18+
parser.add_argument('-v', '--version', help='Dump tool version', dest="ver", action='store_true')
1619

1720
#############################
1821
# Authenticate sub-command

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import shutil
1212
import os, sys, subprocess
1313

14+
from packj import __version__
15+
1416
here = os.path.abspath(os.path.dirname(__file__))
1517

1618
# package descr
@@ -76,7 +78,7 @@ def run(self):
7678
data_files = [
7779
(os.path.expanduser('~'), ['.packj.yaml']),
7880
],
79-
version = '0.13',
81+
version = __version__,
8082
license='GNU AGPLv3',
8183
description = 'Packj flags "risky" open-source packages in your software supply chain',
8284
long_description=long_description,

0 commit comments

Comments
 (0)