Skip to content

Commit

Permalink
Replace 'y' option to 'p' option.
Browse files Browse the repository at this point in the history
Signed-off-by: Jiyeong Seok <jiyeong.seok@lge.com>
  • Loading branch information
dd-jy committed Jul 20, 2022
1 parent fef96c7 commit 673ae74
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
10 changes: 4 additions & 6 deletions src/fosslight_scanner/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
Options:
-h\t\t\t Print help message
-p <path>\t\t Path to analyze
-p <path>\t\t Path to analyze (ex, -p {input_path})
* Compare mode: Two FOSSLight reports in yaml format (ex, -p {before.yaml} {after.yaml})
-w <link>\t\t Link to be analyzed can be downloaded by wget or git clone
-f <format>\t\t FOSSLight Report file format (excel, yaml)
\t\t(In compare mode, supports excel, json, yaml, html)
* Compare mode: supports excel, json, yaml, html
-o <output>\t\t Output directory or file
-c <number>\t\t Number of processes to analyze source
-r\t\t\t Keep raw data
Expand All @@ -36,10 +37,7 @@
-u <db_url>\t\t DB Connection(format :'postgresql://username:password@host:port/database_name')
Options for only 'all' or 'dependency' mode
-d <dependency_argument>\t Additional arguments for running dependency analysis
Options for only 'compare' mode
-y <before yaml> <after yaml> Two FOSSLight reports in yaml format (ex, -y 'before.yaml' 'after.yaml')"""
-d <dependency_argument>\t Additional arguments for running dependency analysis"""


def print_help_msg():
Expand Down
14 changes: 4 additions & 10 deletions src/fosslight_scanner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def main():
parser = ArgumentParser(description='FOSSLight Scanner', prog='fosslight_scanner', add_help=False)
parser.add_argument('mode', nargs='?', help='source| dependency| binary| reuse| all| compare', default="all")
parser.add_argument('--path', '-p', help='Path to analyze', type=str, dest='path', default="")
parser.add_argument('--path', '-p', help='Path to analyze (In compare mode, two FOSSLight reports',
dest='path', nargs='+', default="")
parser.add_argument('--wget', '-w', help='Link to be analyzed', type=str, dest='link', default="")
parser.add_argument('--file', '-f', help='Scanner output file format (excel,yaml), Compare mode (excel,html,yaml,json)',
type=str, dest='file', default="")
Expand All @@ -23,7 +24,7 @@ def main():
parser.add_argument('--timer', '-t', help='Hide the progress bar', action='store_true', dest='timer', default=False)
parser.add_argument('--version', '-v', help='Print version', action='store_true', dest='version', default=False)
parser.add_argument('--help', '-h', help='Print help message', action='store_true', dest='help')
parser.add_argument('--yaml', '-y', help='Two FOSSLight reports in yaml format', nargs=2, default="")

try:
args = parser.parse_args()
except SystemExit:
Expand All @@ -34,15 +35,8 @@ def main():
elif args.version:
print_package_version(PKG_NAME, "FOSSLight Scanner Version:")
else:
if args.yaml:
before_yaml = args.yaml[0]
after_yaml = args.yaml[1]
else:
before_yaml = ''
after_yaml = ''

run_main(args.mode, args.path, args.dep_argument, args.output, args.file,
args.link, args.db_url, args.timer, args.raw, args.core, before_yaml, after_yaml)
args.link, args.db_url, args.timer, args.raw, args.core)


if __name__ == "__main__":
Expand Down
19 changes: 16 additions & 3 deletions src/fosslight_scanner/fosslight_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,30 @@ def init(output_path="", make_outdir=True):
return os.path.isdir(_output_dir), output_root_dir, result_log


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

output_file = ""
default_oss_name = ""
src_path = ""
_executed_path = os.getcwd()

CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'yaml': '.yaml'}
if mode == "compare":
CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'html': '.html', 'json': '.json', 'yaml': '.yaml'}
if isinstance(path_arg, list) and len(path_arg) == 2:
before_yaml = path_arg[0]
after_yaml = path_arg[1]
else:
logger.error("Enter two FOSSLight report file with 'p' option.")
return False
else:
CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'yaml': '.yaml'}
if isinstance(path_arg, list):
if len(path_arg) == 1:
src_path = path_arg[0]
else:
logger.warning(f"Cannot analyze with multiple path: {path_arg}")

success, msg, output_path, output_file, output_extension = check_output_format(output_file_or_dir, file_format,
CUSTOMIZED_FORMAT)
Expand Down

0 comments on commit 673ae74

Please sign in to comment.