Skip to content

Commit

Permalink
Add support to dump version info (feature request)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Bijlani <[email protected]>
  • Loading branch information
ashishbijlani committed Jan 26, 2023
1 parent 64437b6 commit 6e7eca8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions packj/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.14"
6 changes: 6 additions & 0 deletions packj/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def main(config:str='.packj.yaml'):
args = opts.args()
assert args, 'Failed to get cmdline args!'

# version request
if args.ver and not args.cmd:
from packj import __version__
print(__version__)
exit(1)

# configuration file
if not os.path.exists(config):
config = os.path.expanduser(os.path.join('~', f'{config}'))
Expand Down
7 changes: 5 additions & 2 deletions packj/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import argparse
from packj import __version__

class Options():
__args = None
Expand All @@ -9,10 +10,12 @@ def args(self):
return self.__args

def __init__(self, argv):
parser = argparse.ArgumentParser(prog='packj v0.1',
parser = argparse.ArgumentParser(prog=f'packj {__version__}',
usage='main [options] args',
description='Packj flags malicious/risky open-source packages')
subparsers = parser.add_subparsers(title='actions', dest='cmd', help='Command (e.g. audit, sandbox)')
subparsers = parser.add_subparsers(title='actions', dest='cmd', help='Command (e.g. auth, audit, sandbox)')

parser.add_argument('-v', '--version', help='Dump tool version', dest="ver", action='store_true')

#############################
# Authenticate sub-command
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import shutil
import os, sys, subprocess

from packj import __version__

here = os.path.abspath(os.path.dirname(__file__))

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

0 comments on commit 6e7eca8

Please sign in to comment.