Skip to content

Commit

Permalink
🐛 fix --check-license-expression wasnt accepting args.
Browse files Browse the repository at this point in the history
Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm committed May 23, 2024
1 parent f8ceeee commit f858e41
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 58 deletions.
61 changes: 32 additions & 29 deletions ozi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,7 @@
# Part of the OZI Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""OZI - Python Project Packaging console application.
project authoring console application:
ozi-new -h show help for the ozi-new command.
project maintainence console application:
ozi-fix -h show help for the ozi-fix command.
continuous integration checkpoints:
tox -e lint run formatting, linting, and typechecking.
tox -e test run testing and coverage.
tox -e dist run distribution and packaging.
METADATA_FIELD choices:
audience
environment
framework
language
license
license-exception-id
license-id
status
topic
LICENSE_EXPR:
see https://spdx.github.io/spdx-spec/v2-draft/SPDX-license-expressions/
"""``ozi`` console application.
""" # pragma: no cover
from __future__ import annotations # pragma: no cover

Expand All @@ -44,11 +19,39 @@
from ozi.fix.__main__ import main as fix_main # pragma: no cover
from ozi.new.__main__ import main as new_main # pragma: no cover

EPILOG = """
METADATA_FIELD choices:
| audience
| environment
| framework
| language
| license
| license-exception-id
| license-id
| status
| topic
LICENSE_EXPR:
| See https://spdx.github.io/spdx-spec/v2-draft/SPDX-license-expressions/
project authoring console application:
| ozi-new -h show help for the ozi-new command.
project maintainence console application:
| ozi-fix -h show help for the ozi-fix command.
continuous integration checkpoints:
| tox -e lint run formatting, linting, and typechecking.
| tox -e test run testing and coverage.
| tox -e dist run distribution and packaging.
"""

parser = argparse.ArgumentParser(
prog='ozi',
description=sys.modules[__name__].__doc__,
add_help=False,
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=EPILOG,
) # pragma: no cover
tools = parser.add_mutually_exclusive_group() # pragma: no cover
tools.add_argument( # pragma: no cover
Expand Down Expand Up @@ -92,9 +95,8 @@
'-e',
'--check-license-expr',
metavar='LICENSE_EXPR',
action='store_const',
action='store',
default=lambda: None,
const=license_expression,
help=license_expression.__doc__,
)
helpers.add_argument( # pragma: no cover
Expand Down Expand Up @@ -124,7 +126,8 @@ def main() -> None: # pragma: no cover
ozi.info()
if ozi.list_available:
list_available(ozi.list_available)
ozi.check_license_expr()
if ozi.check_license_expr:
license_expression(ozi.check_license_expr)
ozi.fix()
ozi.new()
parser.print_help()
Expand Down
19 changes: 10 additions & 9 deletions ozi/fix/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Part of the OZI Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""``ozi-fix`` argparse argument parser."""
"""``ozi-fix`` console application."""
import argparse
import sys
from argparse import SUPPRESS
Expand All @@ -15,14 +15,14 @@
add_help=False,
usage='%(prog)s [options] | [positional arguments]',
)
subparser = parser.add_subparsers(help='source & test fix', dest='fix')
subparser = parser.add_subparsers(help='', metavar='', dest='fix')

helpers = parser.add_mutually_exclusive_group()
helpers.add_argument('-h', '--help', action='help', help='show this help message and exit')
missing_parser = subparser.add_parser(
'missing',
prog='ozi-fix missing',
aliases=['m'],
aliases=['m', 'mis'],
usage='%(prog)s [options] [output] target',
allow_abbrev=True,
help='Check for missing files in an OZI project.',
Expand All @@ -43,17 +43,18 @@
default=['ozi.phony'],
help=SUPPRESS,
)
missing_parser.add_argument(
missing_output = missing_parser.add_argument_group('output')
missing_output.add_argument(
'--strict',
default=False,
action=BooleanOptionalAction,
help='strict mode raises warnings to errors default: --no-strict',
help='strict mode raises warnings to errors default: ``--no-strict``',
)
missing_parser.add_argument(
missing_output.add_argument(
'--pretty',
default=False,
action=BooleanOptionalAction,
help='pretty mode outputs indented json, default: --no-pretty',
help='pretty mode outputs indented json, default: ``--no-pretty``',
)
missing_parser.add_argument(
'target',
Expand All @@ -64,7 +65,7 @@
)
source_parser = subparser.add_parser(
'source',
aliases=['s'],
aliases=['s', 'src'],
prog='ozi-fix source',
usage='%(prog)s [options] [output] target',
allow_abbrev=True,
Expand All @@ -74,7 +75,7 @@
'test',
prog='ozi-fix test',
usage='%(prog)s [options] [output] target',
aliases=['t'],
aliases=['t', 'tests'],
allow_abbrev=True,
help='Create a new Python test in an OZI project.',
)
Expand Down
2 changes: 1 addition & 1 deletion ozi/new/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Part of the OZI Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""quick-start OZI project creation script."""
"""ozi-new: quick-start OZI project creation script."""
26 changes: 7 additions & 19 deletions ozi/new/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Part of the OZI Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""``ozi-new`` argparse argument parser.
"""``ozi-new`` console application.
"""
from __future__ import annotations

Expand All @@ -18,20 +18,15 @@
add_help=False,
usage='%(prog)s [options] | [positional args]', # noqa: B950,E501,RUF100
)
subparser = parser.add_subparsers(help='create new projects, sources, & tests', dest='new')
subparser = parser.add_subparsers(help='', metavar='', dest='new')
project_parser = subparser.add_parser(
'project',
aliases=['p'],
description='Create a new Python project with OZI.',
add_help=False,
help='create new OZI project',
prog='ozi-new project',
usage='%(prog)s [options] [PKG-INFO required] [PKG-INFO optional] [PKG-INFO defaults] [defaults] target', # noqa: B950,E501,RUF100
)
wrap_parser = subparser.add_parser(
'wrap',
aliases=['w'],
description='Create a new OZI wrapdb file.',
)
required = project_parser.add_argument_group('PKG-INFO required')
optional = project_parser.add_argument_group('PKG-INFO optional')
defaults = project_parser.add_argument_group('PKG-INFO defaults')
Expand Down Expand Up @@ -117,13 +112,6 @@
default='.',
help='directory path for new project',
)
project_output = project_parser.add_mutually_exclusive_group()
project_output.add_argument(
'-h',
'--help',
action='help',
help='show this help message and exit',
)
defaults.add_argument(
'--audience',
'--intended-audience',
Expand Down Expand Up @@ -250,23 +238,23 @@
'--verify-email',
default=False,
action=argparse.BooleanOptionalAction,
help='verify email domain deliverability(default: --no-verify-email)',
help='verify email domain deliverability(default: ``--no-verify-email``)',
)
ozi_defaults.add_argument(
'--enable-cython',
default=False,
action=argparse.BooleanOptionalAction,
help='build extension module with Cython(default: --no-enable-cython)',
help='build extension module with Cython(default: ``--no-enable-cython``)',
)
ozi_defaults.add_argument(
'--strict',
default=False,
action=argparse.BooleanOptionalAction,
help='strict mode raises warnings to errors(default: --strict)',
help='strict mode raises warnings to errors(default: ``--strict``)',
)
ozi_defaults.add_argument(
'--allow-file',
help='Add a file to the allow list for new project target folder(default: [templates, .git])',
help='Add a file to the allow list for new project target folder(default: [templates,.git])',
action='append',
type=str,
nargs='?',
Expand Down

0 comments on commit f858e41

Please sign in to comment.