diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 0c29555..dc78828 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -7,6 +7,7 @@ import itertools import os import shlex import shutil +import sys import tarfile import tempfile import time @@ -185,6 +186,8 @@ def make_diff_metadata(crate, version, patch=False, store=False): def main(): parser = argparse.ArgumentParser("rust2rpm", formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument("--show-license-map", action="store_true", + help="Print license mappings and exit") parser.add_argument("-", "--stdout", action="store_true", help="Print spec and patches into stdout") parser.add_argument("-t", "--target", action="store", @@ -196,10 +199,18 @@ def main(): help="Store crate in current directory") parser.add_argument("crate", help="crates.io name\n" "path/to/local.crate\n" - "path/to/project/") + "path/to/project/", + nargs="?") parser.add_argument("version", nargs="?", help="crates.io version") args = parser.parse_args() + if args.show_license_map: + licensing.dump_sdpx_to_fedora_map(sys.stdout) + return + + if args.crate is None: + parser.error('required crate/path argument missing') + crate, diff, metadata = make_diff_metadata(args.crate, args.version, patch=args.patch, store=args.store_crate) diff --git a/rust2rpm/licensing.py b/rust2rpm/licensing.py index 1b9015e..964603e 100644 --- a/rust2rpm/licensing.py +++ b/rust2rpm/licensing.py @@ -21,6 +21,10 @@ def spdx_to_fedora_map(): for line in reader if line['SPDX License Identifier']} +def dump_sdpx_to_fedora_map(file): + for k,v in spdx_to_fedora_map().items(): + print(f"{k} → {v}", file=file) + def translate_license_fedora(license): comments = '' final = []