Skip to content

Commit 45bee15

Browse files
authored
Modify to print help message and Use Flake8 v3.9.2 to use tox
2 parents 15043a6 + 23d0c41 commit 45bee15

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tox
2+
flake8==3.9.2
23
pytest
34
pytest-cov
45
pytest-flake8

src/fosslight_reuse/_help.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
from fosslight_util.help import PrintHelpMsg
66

77
_HELP_MESSAGE_REUSE = """
8-
Usage: fosslight_reuse [Mode] [option1] <arg1> [option2] <arg2>...
9-
ex) fosslight_reuse lint -p /home/test/ -f "notice/sample.py,src/init.py"
10-
fosslight_reuse add -p /home/test/ -c "Copyright 2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
11-
128
FOSSLight Reuse is a Tool to check REUSE compliance in source code.
139
10+
Usage: fosslight_reuse [Mode] [option1] <arg1> [option2] <arg2>...
11+
ex) fosslight_reuse lint -p /home/test/ -f "notice/sample.py,src/init.py"
12+
fosslight_reuse add -p /home/test/ -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
13+
1414
Parameters:
1515
Mode
1616
lint\t\t Check REUSE compliance
17-
report\t\t oss_pkg_info.yaml <-> FOSSLight-Report.xml
17+
report\t\t oss_pkg_info.yaml <-> FOSSLight-Report.xlsx
1818
add\t\t\t Add missing license and copyright
1919
2020
Options:
@@ -25,7 +25,7 @@
2525
-n\t\t\t Don't exclude venv*, node_modules, and .*/ from the analysis
2626
Options for only 'add' mode
2727
-l <license>\t License name(SPDX format) to add
28-
-c <copyright>\t Copyright to add(ex, Copyright 2015-2021 LGE Electronics Inc.)"""
28+
-c <copyright>\t Copyright to add(ex, 2015-2021 LG Electronics Inc.)"""
2929

3030

3131
def print_help_msg(exitOpt=True):

src/fosslight_reuse/cli.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,29 @@
33
# Copyright (c) 2021 LG Electronics Inc.
44
# SPDX-License-Identifier: GPL-3.0-only
55
import argparse
6-
from ._help import _HELP_MESSAGE_REUSE
6+
from ._help import print_help_msg
77
from ._fosslight_reuse import run_lint
88
from fosslight_oss_pkg.fosslight_oss_pkg import convert_report
99
from ._add import add_content
1010

1111

1212
def main():
13-
parser = argparse.ArgumentParser(description='FOSSLight Reuse', usage=_HELP_MESSAGE_REUSE)
13+
parser = argparse.ArgumentParser(description='FOSSLight Reuse', prog='fosslight_reuse', add_help=False)
1414
parser.add_argument('mode', help='lint | report | add')
1515
parser.add_argument('--path', '-p', help='Path to check', type=str, dest='path', default="")
1616
parser.add_argument('--file', '-f', help='Files to check', type=str, dest='file', default="")
1717
parser.add_argument('--output', '-o', help='Output file name', type=str, dest='output', default="")
1818
parser.add_argument('--no', '-n', help='Disable automatic exclude mode', action='store_true', dest='disable')
1919
parser.add_argument('--license', '-l', help='License name to add', type=str, dest='license', default="")
2020
parser.add_argument('--copyright', '-c', help='Copyright to add', type=str, dest='copyright', default="")
21-
args = parser.parse_args()
21+
parser.add_argument('--help', '-h', help='Print help message', action='store_true', dest='help')
22+
try:
23+
args = parser.parse_args()
24+
except SystemExit:
25+
print_help_msg()
26+
27+
if args.help:
28+
print_help_msg()
2229

2330
if args.mode == "lint":
2431
run_lint(args.path, args.file, args.disable, args.output)

0 commit comments

Comments
 (0)