Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion spdx_license_matcher/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import codecs
import redis

from spdx_license_matcher.build_licenses import build_spdx_licenses, is_keys_empty,get_url
from spdx_license_matcher.build_licenses import build_spdx_licenses, is_keys_empty
from spdx_license_matcher.computation import get_close_matches, get_matching_string
from spdx_license_matcher.difference import generate_diff, get_similarity_percent
from spdx_license_matcher.utils import colors, get_spdx_license_text
Expand All @@ -12,10 +12,21 @@

load_dotenv()

def _print_version_callback(ctx, param, value):
if not value or ctx.resilient_parsing:
return
try:
from spdx_license_matcher import __version__ as ver
except Exception:
ver = 'unknown'
click.echo(ver)
ctx.exit()

@click.command()
@click.option('--text_file', '-f', required=True, help='The name of the file in which there is the text you want to match against the SPDX License database.')
@click.option('--threshold', '-t', default=0.9, type = click.FloatRange(0.0, 1.0), help='Confidence threshold below which we just won"t consider it a match.', show_default=True)
@click.option('--build/--no-build', default=False, help='Builds the SPDX license list in the database. If licenses are already present it will update the redis database.')
@click.option('--version', '-V', is_flag=True, is_eager=True, callback=_print_version_callback, expose_value=False, help='Show version and exit.')
def matcher(text_file, threshold, build):
"""SPDX License matcher to match license text against the SPDX license list using an algorithm which finds close matches. """
try:
Expand Down