Skip to content

Commit ca38b8b

Browse files
authored
Merge pull request #41 from fosslight/develop
Replace 'y' option to 'p' option.
2 parents e07e2cb + 673ae74 commit ca38b8b

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

src/fosslight_scanner/_help.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
2323
Options:
2424
-h\t\t\t Print help message
25-
-p <path>\t\t Path to analyze
25+
-p <path>\t\t Path to analyze (ex, -p {input_path})
26+
* Compare mode: Two FOSSLight reports in yaml format (ex, -p {before.yaml} {after.yaml})
2627
-w <link>\t\t Link to be analyzed can be downloaded by wget or git clone
2728
-f <format>\t\t FOSSLight Report file format (excel, yaml)
28-
\t\t(In compare mode, supports excel, json, yaml, html)
29+
* Compare mode: supports excel, json, yaml, html
2930
-o <output>\t\t Output directory or file
3031
-c <number>\t\t Number of processes to analyze source
3132
-r\t\t\t Keep raw data
@@ -36,10 +37,7 @@
3637
-u <db_url>\t\t DB Connection(format :'postgresql://username:password@host:port/database_name')
3738
3839
Options for only 'all' or 'dependency' mode
39-
-d <dependency_argument>\t Additional arguments for running dependency analysis
40-
41-
Options for only 'compare' mode
42-
-y <before yaml> <after yaml> Two FOSSLight reports in yaml format (ex, -y 'before.yaml' 'after.yaml')"""
40+
-d <dependency_argument>\t Additional arguments for running dependency analysis"""
4341

4442

4543
def print_help_msg():

src/fosslight_scanner/cli.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
def main():
1212
parser = ArgumentParser(description='FOSSLight Scanner', prog='fosslight_scanner', add_help=False)
1313
parser.add_argument('mode', nargs='?', help='source| dependency| binary| reuse| all| compare', default="all")
14-
parser.add_argument('--path', '-p', help='Path to analyze', type=str, dest='path', default="")
14+
parser.add_argument('--path', '-p', help='Path to analyze (In compare mode, two FOSSLight reports',
15+
dest='path', nargs='+', default="")
1516
parser.add_argument('--wget', '-w', help='Link to be analyzed', type=str, dest='link', default="")
1617
parser.add_argument('--file', '-f', help='Scanner output file format (excel,yaml), Compare mode (excel,html,yaml,json)',
1718
type=str, dest='file', default="")
@@ -23,7 +24,7 @@ def main():
2324
parser.add_argument('--timer', '-t', help='Hide the progress bar', action='store_true', dest='timer', default=False)
2425
parser.add_argument('--version', '-v', help='Print version', action='store_true', dest='version', default=False)
2526
parser.add_argument('--help', '-h', help='Print help message', action='store_true', dest='help')
26-
parser.add_argument('--yaml', '-y', help='Two FOSSLight reports in yaml format', nargs=2, default="")
27+
2728
try:
2829
args = parser.parse_args()
2930
except SystemExit:
@@ -34,15 +35,8 @@ def main():
3435
elif args.version:
3536
print_package_version(PKG_NAME, "FOSSLight Scanner Version:")
3637
else:
37-
if args.yaml:
38-
before_yaml = args.yaml[0]
39-
after_yaml = args.yaml[1]
40-
else:
41-
before_yaml = ''
42-
after_yaml = ''
43-
4438
run_main(args.mode, args.path, args.dep_argument, args.output, args.file,
45-
args.link, args.db_url, args.timer, args.raw, args.core, before_yaml, after_yaml)
39+
args.link, args.db_url, args.timer, args.raw, args.core)
4640

4741

4842
if __name__ == "__main__":

src/fosslight_scanner/fosslight_scanner.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,30 @@ def init(output_path="", make_outdir=True):
262262
return os.path.isdir(_output_dir), output_root_dir, result_log
263263

264264

265-
def run_main(mode, src_path, dep_arguments, output_file_or_dir, file_format, url_to_analyze, db_url,
266-
hide_progressbar=False, keep_raw_data=False, num_cores=-1, before_yaml="", after_yaml=""):
265+
def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url_to_analyze, db_url,
266+
hide_progressbar=False, keep_raw_data=False, num_cores=-1):
267267
global _executed_path, _start_time
268268

269269
output_file = ""
270270
default_oss_name = ""
271+
src_path = ""
271272
_executed_path = os.getcwd()
272273

273-
CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'yaml': '.yaml'}
274274
if mode == "compare":
275275
CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'html': '.html', 'json': '.json', 'yaml': '.yaml'}
276+
if isinstance(path_arg, list) and len(path_arg) == 2:
277+
before_yaml = path_arg[0]
278+
after_yaml = path_arg[1]
279+
else:
280+
logger.error("Enter two FOSSLight report file with 'p' option.")
281+
return False
282+
else:
283+
CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'yaml': '.yaml'}
284+
if isinstance(path_arg, list):
285+
if len(path_arg) == 1:
286+
src_path = path_arg[0]
287+
else:
288+
logger.warning(f"Cannot analyze with multiple path: {path_arg}")
276289

277290
success, msg, output_path, output_file, output_extension = check_output_format(output_file_or_dir, file_format,
278291
CUSTOMIZED_FORMAT)

0 commit comments

Comments
 (0)