Skip to content

Commit 58d772f

Browse files
committed
feat: ES-163 add best match and treshold arguments to hfh scan command
1 parent 86833bc commit 58d772f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/scanoss/cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,17 @@ def setup_args() -> None: # noqa: PLR0915
488488
choices=['plain', 'json'],
489489
help='Result output format (optional - default: plain)',
490490
)
491+
p_folder_scan.add_argument(
492+
'--best-match',
493+
'-bm',
494+
action='store_true',
495+
help='Enable best match mode (optional - default: False)',
496+
)
497+
p_folder_scan.add_argument(
498+
'--threshold',
499+
type=int,
500+
help='Threshold for result matching (optional - default: 100)',
501+
)
491502
p_folder_scan.set_defaults(func=folder_hashing_scan)
492503

493504
# Scanoss settings options
@@ -1470,13 +1481,17 @@ def folder_hashing_scan(parser, args):
14701481
grpc_config = create_grpc_config_from_args(args)
14711482

14721483
client = ScanossGrpc(**asdict(grpc_config))
1484+
14731485
scanner = ScannerHFH(
14741486
scan_dir=args.scan_dir,
14751487
config=scanner_config,
14761488
client=client,
14771489
scanoss_settings=scanoss_settings,
14781490
)
14791491

1492+
scanner.best_match = args.best_match
1493+
scanner.threshold = args.threshold
1494+
14801495
scanner.scan()
14811496
scanner.present(output_file=args.output, output_format=args.format)
14821497
except ScanossGrpcError as e:

src/scanoss/scanners/scanner_hfh.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def __init__(
106106
self.scan_dir = scan_dir
107107
self.client = client
108108
self.scan_results = None
109+
self.best_match = False
110+
self.threshold = 100
109111

110112
def scan(self) -> Optional[Dict]:
111113
"""
@@ -116,8 +118,8 @@ def scan(self) -> Optional[Dict]:
116118
"""
117119
hfh_request = {
118120
'root': self.hfh_request_from_path(self.scan_dir),
119-
'threshold': 100,
120-
'best_match': True,
121+
'threshold': self.threshold,
122+
'best_match': self.best_match,
121123
}
122124

123125
response = self.client.folder_hash_scan(hfh_request)

0 commit comments

Comments
 (0)