Skip to content

Commit 12101e5

Browse files
authored
Merge pull request #57 from fosslight/develop
Add the -v option to print the installed version of FOSSLight Source Scanner
2 parents ce39208 + ea58265 commit 12101e5

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scancode-toolkit
22
typecode_libmagic
33
XlsxWriter
4-
fosslight_util>=1.3.4
4+
fosslight_util>=1.3.8
55
PyYAML
66
wheel

src/fosslight_source/_help.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
# Copyright (c) 2021 LG Electronics Inc.
44
# SPDX-License-Identifier: Apache-2.0
5-
from fosslight_util.help import PrintHelpMsg
5+
from fosslight_util.help import PrintHelpMsg, print_package_version
66

77
_HELP_MESSAGE_SOURCE = """
88
Usage: fosslight_source [option1] <arg1> [option2] <arg2>...
@@ -19,6 +19,7 @@
1919
2020
Optional
2121
-h\t\t\t\t Print help message
22+
-v\t\t\t\t Print FOSSLight Source Scanner version
2223
-j\t\t\t\t Generate raw result of scanners in json format
2324
-m\t\t\t\t Print the Matched text for each license on a separate sheet (Scancode Only)
2425
-o <output_path>\t\t Output path
@@ -37,12 +38,17 @@
3738
3839
Optional
3940
-h\t\t\t\t Print help message
41+
-v\t\t\t\t Print FOSSLight Source Scanner version
4042
-m\t\t\t\t Print the Matched text for each license on a separate sheet
4143
-o <output_path>\t\t Output path
4244
\t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
4345
-f <format>\t\t\t Output file format (excel, csv, opossum)"""
4446

4547

48+
def print_version(pkg_name):
49+
print_package_version(pkg_name, "FOSSLight Source Scanner Version")
50+
51+
4652
def print_help_msg_source():
4753
helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE)
4854
helpMsg.print_help_msg(True)

src/fosslight_source/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import fosslight_util.constant as constant
1414
from fosslight_util.set_log import init_log
1515
from fosslight_util.timer_thread import TimerThread
16-
from ._help import print_help_msg_source
16+
from ._help import print_help_msg_source, print_version
1717
from ._license_matched import get_license_list_to_print
1818
from fosslight_util.output_format import check_output_format, write_output_file
1919
from .run_scancode import run_scan
@@ -48,10 +48,12 @@ def main():
4848
license_list = []
4949

5050
try:
51-
opts, args = getopt.getopt(argv, 'hmjs:p:o:f:')
51+
opts, args = getopt.getopt(argv, 'hvmjs:p:o:f:')
5252
for opt, arg in opts:
5353
if opt == "-h":
5454
print_help_msg_source()
55+
elif opt == "-v":
56+
print_version(_PKG_NAME)
5557
elif opt == "-p":
5658
path_to_scan = arg
5759
elif opt == "-j":

src/fosslight_source/convert_scancode.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import yaml
1515
from ._parsing_scancode_file_item import parsing_file_item, get_error_from_header
1616
from fosslight_util.output_format import check_output_format, write_output_file
17-
from ._help import print_help_msg_convert
17+
from ._help import print_help_msg_convert, print_version
1818
from ._license_matched import get_license_list_to_print
1919

2020
logger = logging.getLogger(constant.LOGGER_NAME)
@@ -133,10 +133,12 @@ def main():
133133
format = ""
134134

135135
try:
136-
opts, args = getopt.getopt(argv, 'hmp:o:f:')
136+
opts, args = getopt.getopt(argv, 'hvmp:o:f:')
137137
for opt, arg in opts:
138138
if opt == "-h":
139139
print_help_msg_convert()
140+
elif opt == "-v":
141+
print_version(_PKG_NAME)
140142
elif opt == "-p":
141143
path_to_find_json = arg
142144
elif opt == "-o":

0 commit comments

Comments
 (0)