Skip to content

Commit aa12866

Browse files
committed
Add a version argument to tern CLI
This commit adds a --version option to Tern's CLI. This option will display the version of Tern that is installed and also output the python version. This commit also updates the GitHub issue template. This will be useful for individuals opening bugs to provide the version of Tern that they are opening the issue against. Resolves tern-tools#209 Signed-off-by: Rose Judge <[email protected]>
1 parent cd41a42 commit aa12866

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A clear and concise description of what you expected to happen.
2424

2525
**Environment you are running Tern on**
2626
Enter all that apply
27+
- Output of 'tern --version'
2728
- Operating System (Linux Distro and version or Mac or Windows)
2829
- Vagrant file
2930
- Container OS

tern/__main__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
import importlib
1414
import logging
1515
import os
16+
import sys
1617

1718
from tern.report import report
1819
from tern.utils import cache
1920
from tern.utils import constants
21+
from tern import Version
22+
2023

2124
# global logger
2225
logger = logging.getLogger(constants.logger_name)
@@ -77,6 +80,7 @@ def do_main(args):
7780

7881
def main():
7982
parser = argparse.ArgumentParser(
83+
formatter_class=argparse.RawTextHelpFormatter,
8084
prog='Tern',
8185
description='''
8286
Tern is a container image component curation tool. Tern retrieves
@@ -95,6 +99,11 @@ def main():
9599
"Needed when running from within a container")
96100
parser.add_argument('-r', '--redo', action='store_true',
97101
help="Repopulate the cache for found layers")
102+
# sys.version gives more information than we care to print
103+
py_ver = sys.version.replace('\n', '').split('[')[0]
104+
parser.add_argument('-V', '--version', action='version',
105+
version="%(prog)s {0}\n python version = {1}".format(
106+
Version, py_ver))
98107
subparsers = parser.add_subparsers(help='Subcommands')
99108
# subparser for report
100109
parser_report = subparsers.add_parser('report',

0 commit comments

Comments
 (0)