diff --git a/requirements.txt b/requirements.txt index 89432c2..2290de6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ scancode-toolkit typecode_libmagic XlsxWriter -fosslight_util>=1.3.4 +fosslight_util>=1.3.8 PyYAML wheel diff --git a/src/fosslight_source/_help.py b/src/fosslight_source/_help.py index 44b0ace..9f69d73 100644 --- a/src/fosslight_source/_help.py +++ b/src/fosslight_source/_help.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2021 LG Electronics Inc. # SPDX-License-Identifier: Apache-2.0 -from fosslight_util.help import PrintHelpMsg +from fosslight_util.help import PrintHelpMsg, print_package_version _HELP_MESSAGE_SOURCE = """ Usage: fosslight_source [option1] [option2] ... @@ -19,6 +19,7 @@ Optional -h\t\t\t\t Print help message + -v\t\t\t\t Print FOSSLight Source Scanner version -j\t\t\t\t Generate raw result of scanners in json format -m\t\t\t\t Print the Matched text for each license on a separate sheet (Scancode Only) -o \t\t Output path @@ -37,12 +38,17 @@ Optional -h\t\t\t\t Print help message + -v\t\t\t\t Print FOSSLight Source Scanner version -m\t\t\t\t Print the Matched text for each license on a separate sheet -o \t\t Output path \t\t\t\t (If you want to generate the specific file name, add the output path with file name.) -f \t\t\t Output file format (excel, csv, opossum)""" +def print_version(pkg_name): + print_package_version(pkg_name, "FOSSLight Source Scanner Version") + + def print_help_msg_source(): helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE) helpMsg.print_help_msg(True) diff --git a/src/fosslight_source/cli.py b/src/fosslight_source/cli.py index bc42f04..c05a3da 100755 --- a/src/fosslight_source/cli.py +++ b/src/fosslight_source/cli.py @@ -13,7 +13,7 @@ import fosslight_util.constant as constant from fosslight_util.set_log import init_log from fosslight_util.timer_thread import TimerThread -from ._help import print_help_msg_source +from ._help import print_help_msg_source, print_version from ._license_matched import get_license_list_to_print from fosslight_util.output_format import check_output_format, write_output_file from .run_scancode import run_scan @@ -48,10 +48,12 @@ def main(): license_list = [] try: - opts, args = getopt.getopt(argv, 'hmjs:p:o:f:') + opts, args = getopt.getopt(argv, 'hvmjs:p:o:f:') for opt, arg in opts: if opt == "-h": print_help_msg_source() + elif opt == "-v": + print_version(_PKG_NAME) elif opt == "-p": path_to_scan = arg elif opt == "-j": diff --git a/src/fosslight_source/convert_scancode.py b/src/fosslight_source/convert_scancode.py index 92c5b2c..822591c 100755 --- a/src/fosslight_source/convert_scancode.py +++ b/src/fosslight_source/convert_scancode.py @@ -14,7 +14,7 @@ import yaml from ._parsing_scancode_file_item import parsing_file_item, get_error_from_header from fosslight_util.output_format import check_output_format, write_output_file -from ._help import print_help_msg_convert +from ._help import print_help_msg_convert, print_version from ._license_matched import get_license_list_to_print logger = logging.getLogger(constant.LOGGER_NAME) @@ -133,10 +133,12 @@ def main(): format = "" try: - opts, args = getopt.getopt(argv, 'hmp:o:f:') + opts, args = getopt.getopt(argv, 'hvmp:o:f:') for opt, arg in opts: if opt == "-h": print_help_msg_convert() + elif opt == "-v": + print_version(_PKG_NAME) elif opt == "-p": path_to_find_json = arg elif opt == "-o":