Skip to content

Commit aa781b0

Browse files
committed
Allow for extra arguments to hatchling build
1 parent 5352e44 commit aa781b0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

backend/src/hatchling/cli/__init__.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ def hatchling() -> int:
1717
metadata_command(subparsers, defaults)
1818
version_command(subparsers, defaults)
1919

20-
kwargs = vars(parser.parse_args())
20+
# Parse known arguments
21+
kwargs, extras = parser.parse_known_args()
22+
23+
# Extras can exist to be detected in custom hooks and plugins,
24+
# but they must be after a '--' separator
25+
if extras and not extras[0] == "--":
26+
parser.print_help()
27+
return 1
28+
29+
# Wrap the parsed arguments in a dictionary
30+
kwargs = vars(kwargs)
31+
2132
try:
2233
command = kwargs.pop('func')
2334
except KeyError:

0 commit comments

Comments
 (0)