Skip to content

Commit 370f915

Browse files
Unify help message for scanner and converter
1 parent 281117e commit 370f915

File tree

4 files changed

+23
-39
lines changed

4 files changed

+23
-39
lines changed

src/fosslight_source/_help.py

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,36 @@
44
# SPDX-License-Identifier: Apache-2.0
55
from fosslight_util.help import PrintHelpMsg, print_package_version
66

7-
_HELP_MESSAGE_SOURCE = """
8-
Usage: fosslight_source [option1] <arg1> [option2] <arg2>...
7+
_HELP_MESSAGE_SOURCE_SCANNER = """
8+
FOSSLight Source Scanner Usage: fosslight_source [option1] <arg1> [option2] <arg2>...
99
10-
FOSSLight Source uses ScanCode, a source code scanner, to detect the copyright and license phrases
11-
contained in the file. Some files (ex- build script), binary files, directory and files in specific
10+
FOSSLight Source Scanner uses ScanCode and SCANOSS, the source code scanners, to detect
11+
the copyright and license phrases contained in the file.
12+
Some files (ex- build script), binary files, directory and files in specific
1213
directories (ex-test) are excluded from the result.
13-
And removes words such as “-only” and “-old-style” from the license name to be printed.
14-
The output result is generated in Excel format.
14+
15+
FOSSLight Convert Usage: fosslight_convert [option1] <arg1> [option2] <arg2>...
16+
17+
FOSSLigtht Converter converts the result of ScanCode in json format into FOSSLight Report format.
1518
1619
Options:
1720
Optional
1821
-p <source_path>\t Path to analyze source (Default: current directory)
1922
-h\t\t\t Print help message
2023
-v\t\t\t Print FOSSLight Source Scanner version
21-
-j\t\t\t Generate raw result of scanners in json format
2224
-m\t\t\t Print additional information for scan result on separate sheets
2325
-o <output_path>\t Output path (Path or file name)
2426
-f <format>\t\t Output file format (excel, csv, opossum, yaml)
27+
Options only for FOSSLight Source Scanner
2528
-s <scanner>\t Select which scanner to be run (scancode, scanoss, all)
29+
-j\t\t\t Generate raw result of scanners in json format
2630
-t <float>\t\t Stop scancode scanning if scanning takes longer than a timeout in seconds."""
2731

28-
_HELP_MESSAGE_CONVERT = """
29-
Usage: fosslight_convert [option1] <arg1> [option2] <arg2>...
30-
31-
FOSSLigtht_convert converts the result of executing ScanCode in json format into FOSSLight Report format.
32-
33-
Options:
34-
Optional
35-
-p <path_dir>\t\t Path of ScanCode json files (Default: current directory)
36-
-h\t\t\t\t Print help message
37-
-v\t\t\t\t Print FOSSLight Source Scanner version
38-
-m\t\t\t\t Print the Matched text for each license on a separate sheet
39-
-o <output_path>\t\t Output path
40-
\t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
41-
-f <format>\t\t\t Output file format (excel, csv, opossum)"""
42-
4332

4433
def print_version(pkg_name):
4534
print_package_version(pkg_name, "FOSSLight Source Scanner Version")
4635

4736

48-
def print_help_msg_source():
49-
helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE)
50-
helpMsg.print_help_msg(True)
51-
52-
53-
def print_help_msg_convert():
54-
helpMsg = PrintHelpMsg(_HELP_MESSAGE_CONVERT)
37+
def print_help_msg_source_scanner():
38+
helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE_SCANNER)
5539
helpMsg.print_help_msg(True)

src/fosslight_source/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import fosslight_util.constant as constant
1313
from fosslight_util.set_log import init_log
1414
from fosslight_util.timer_thread import TimerThread
15-
from ._help import print_help_msg_source, print_version
15+
from ._help import print_version, print_help_msg_source_scanner
1616
from ._license_matched import get_license_list_to_print
1717
from fosslight_util.output_format import check_output_format, write_output_file
1818
from .run_scancode import run_scan
@@ -66,7 +66,7 @@ def main():
6666
args = parser.parse_args()
6767

6868
if args.help:
69-
print_help_msg_source()
69+
print_help_msg_source_scanner()
7070
if args.version:
7171
print_version(_PKG_NAME)
7272
if not args.path:
@@ -111,7 +111,7 @@ def main():
111111
print_matched_text, format, True,
112112
time_out)
113113
else:
114-
print_help_msg_source()
114+
print_help_msg_source_scanner()
115115
sys.exit(1)
116116
create_report_file(_start_time, scanned_result, license_list, selected_scanner, print_matched_text,
117117
output_path, output_file, output_extension)

src/fosslight_source/convert_scancode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import yaml
1313
from ._parsing_scancode_file_item import parsing_file_item, get_error_from_header
1414
from fosslight_util.output_format import check_output_format, write_output_file
15-
from ._help import print_help_msg_convert, print_version
15+
from ._help import print_version, print_help_msg_source_scanner
1616
from ._license_matched import get_license_list_to_print
1717
import argparse
1818

@@ -145,7 +145,7 @@ def main():
145145
args = parser.parse_args()
146146

147147
if args.help:
148-
print_help_msg_convert()
148+
print_help_msg_source_scanner()
149149
if args.version:
150150
print_version(_PKG_NAME)
151151
if not args.path:
@@ -159,7 +159,7 @@ def main():
159159
format = ''.join(args.format)
160160

161161
if path_to_find_json == "":
162-
print_help_msg_convert()
162+
print_help_msg_source_scanner()
163163

164164
convert_json_to_output_report(path_to_find_json, output_file_name, print_matched_text, format)
165165

tests/test_files/run_scancode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ._parsing_scancode_file_item import parsing_file_item
2020
from ._parsing_scancode_file_item import get_error_from_header
2121
from fosslight_util.write_excel import write_excel_and_csv
22-
from ._help import print_help_msg_source
22+
from ._help import print_help_msg_source_scanner
2323
from ._license_matched import get_license_list_to_print
2424

2525
logger = logging.getLogger(constant.LOGGER_NAME)
@@ -38,7 +38,7 @@ def main():
3838
opts, args = getopt.getopt(argv, 'hmjp:o:')
3939
for opt, arg in opts:
4040
if opt == "-h":
41-
print_help_msg_source()
41+
print_help_msg_source_scanner()
4242
elif opt == "-p":
4343
path_to_scan = arg
4444
elif opt == "-j":
@@ -48,7 +48,7 @@ def main():
4848
elif opt == "-m":
4949
print_matched_text = True
5050
except Exception:
51-
print_help_msg_source()
51+
print_help_msg_source_scanner()
5252

5353
timer = TimerThread()
5454
timer.setDaemon(True)
@@ -85,7 +85,7 @@ def run_scan(path_to_scan, output_file_name="",
8585
if _windows:
8686
path_to_scan = os.getcwd()
8787
else:
88-
print_help_msg_source()
88+
print_help_msg_source_scanner()
8989

9090
num_cores = multiprocessing.cpu_count() - 1 if num_cores < 0 else num_cores
9191

0 commit comments

Comments
 (0)