Skip to content

Commit 84eda21

Browse files
Make license references a CLI option #3269
Moved license references to a CLI option and not default. Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 964cef9 commit 84eda21

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/licensedcode/licenses_reference.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from licensedcode.models import Rule
1515
from plugincode.post_scan import PostScanPlugin
1616
from plugincode.post_scan import post_scan_impl
17+
from commoncode.cliutils import PluggableCommandLineOption
18+
from commoncode.cliutils import POST_SCAN_GROUP
1719
import attr
1820

1921
TRACE = os.environ.get('SCANCODE_DEBUG_LICENSE_REFERENCE', False)
@@ -48,8 +50,18 @@ class LicenseReference(PostScanPlugin):
4850
# TODO: send to the tail of the scan, after files
4951
sort_order = 1000
5052

51-
def is_enabled(self, **kwargs):
52-
return kwargs.get('license') or kwargs.get('package')
53+
options = [
54+
PluggableCommandLineOption(('--license-references',),
55+
is_flag=True,
56+
help='Return reference data for all licenses and license rules'
57+
'present in detections.',
58+
help_group=POST_SCAN_GROUP,
59+
sort_order=100,
60+
)
61+
]
62+
63+
def is_enabled(self, license_references, **kwargs):
64+
return license_references
5365

5466
def process_codebase(self, codebase, **kwargs):
5567
"""

tests/licensedcode/test_licenses_reference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_licenses_reference_works():
2424
test_dir = test_env.get_test_loc('licenses_reference_reporting/scan', copy=True)
2525
result_file = test_env.get_temp_file('json')
2626
args = [
27-
'--license', '--package',
27+
'--license', '--package', '--license-references',
2828
test_dir, '--json-pp', result_file, '--verbose'
2929
]
3030
run_scan_click(args)
@@ -38,7 +38,7 @@ def test_licenses_reference_works_with_matched_text():
3838
result_file = test_env.get_temp_file('json')
3939
args = [
4040
'--license', '--package', '--license-text', '--license-text-diagnostics',
41-
test_dir, '--json-pp', result_file, '--verbose'
41+
'--license-references', test_dir, '--json-pp', result_file, '--verbose'
4242
]
4343
run_scan_click(args)
4444
check_json_scan(
@@ -51,7 +51,7 @@ def test_licenses_reference_works_with_license_clues():
5151
result_file = test_env.get_temp_file('json')
5252
args = [
5353
'--license', '--license-text', '--license-text-diagnostics',
54-
test_dir, '--json-pp', result_file, '--verbose'
54+
'--license-references', test_dir, '--json-pp', result_file, '--verbose'
5555
]
5656
run_scan_click(args)
5757
check_json_scan(

0 commit comments

Comments
 (0)