Skip to content

Commit

Permalink
Allow for extra arguments to hatchling build
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Oct 3, 2024
1 parent 5352e44 commit 052118a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/src/hatchling/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ def hatchling() -> int:
metadata_command(subparsers, defaults)
version_command(subparsers, defaults)

kwargs = vars(parser.parse_args())
# Parse known arguments
kwargs, extras = parser.parse_known_args()

# Extras can exist to be detected in custom hooks and plugins,
# but they must be after a '--' separator
if extras and extras[0] != "--":
parser.print_help()
return 1

# Wrap the parsed arguments in a dictionary
kwargs = vars(kwargs)

try:
command = kwargs.pop('func')
except KeyError:
Expand Down

0 comments on commit 052118a

Please sign in to comment.