Skip to content

Commit bcb5f0f

Browse files
committed
Exit if input -c or -l, when not add mode
1 parent a16d767 commit bcb5f0f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/fosslight_prechecker/_add.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def convert_to_spdx_style(input_string):
9292

9393

9494
def check_input_license_format(input_license):
95+
global spdx_licenses
9596
if input_license in spdx_licenses:
9697
return input_license
9798

@@ -390,7 +391,7 @@ def download_oss_info_license(base_path, input_license=""):
390391

391392

392393
def add_content(target_path="", input_license="", input_copyright="", output_path="", need_log_file=True):
393-
global _result_log
394+
global _result_log, spdx_licenses
394395
_check_only_file_mode = False
395396
file_to_check_list = []
396397

src/fosslight_prechecker/cli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
from fosslight_prechecker._precheck import run_lint
1414

1515

16-
def run_main(mode, path, output, format, no_log, disable, copyright, license):
16+
def run_main(mode, path, output, format, no_log, disable, copyright, license, parser):
17+
if mode != "add" and (copyright != "" or license != ""):
18+
parser.print_help()
19+
sys.exit(1)
20+
1721
if mode == "lint":
1822
run_lint(path, disable, output, format, no_log)
1923
elif mode == "add":
@@ -34,8 +38,8 @@ def main():
3438
parser.add_argument('-p', '--path', help='Path to check', type=str, dest='path', default="")
3539
parser.add_argument('-f', '--format', help='Format of ouput', type=str, dest='format', default="")
3640
parser.add_argument('-o', '--output', help='Output file name', type=str, dest='output', default="")
37-
parser.add_argument('-l', '--license', help='License name to add', type=str, dest='license', default="")
38-
parser.add_argument('-c', '--copyright', help='Copyright to add', type=str, dest='copyright', default="")
41+
parser.add_argument('-l', '--license', help="License name to add(used in only 'add' mode)", type=str, dest='license', default="")
42+
parser.add_argument('-c', '--copyright', help="Copyright to add(used in only 'add' mode)", type=str, dest='copyright', default="")
3943
parser.add_argument('--notice', action='store_true', required=False)
4044
try:
4145
args = parser.parse_args()
@@ -62,7 +66,7 @@ def main():
6266
print(f.read())
6367
else:
6468
run_main(args.mode, args.path, args.output, args.format,
65-
args.log, args.disable, args.copyright, args.license)
69+
args.log, args.disable, args.copyright, args.license, parser)
6670

6771

6872
if __name__ == "__main__":

0 commit comments

Comments
 (0)