From bbe43f4c8fa26e752cb0921b642d602ff14235ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 8 Oct 2022 14:21:03 +0200 Subject: fixup! wip: saturday fixup --- pydanclick/core.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pydanclick/core.py b/pydanclick/core.py index 6eb2280..4bc4c20 100644 --- a/pydanclick/core.py +++ b/pydanclick/core.py @@ -88,7 +88,6 @@ def get_processable_arguments( def get_option_arguments( - schema: CliSchema, parameter: CliSchema.PropertySchema, key: str, ) -> OptionArgumentsSchema: @@ -96,10 +95,7 @@ def get_option_arguments( Generate the option information only of a click.Command. """ - arguments = OptionArgumentsSchema( - help=parameter.description, - required=key in schema.required, - ) + arguments = OptionArgumentsSchema(help=parameter.description) option_min = parameter.minLength or parameter.exclusiveMinimum option_max = parameter.maxLength or parameter.exlusiveMaximum @@ -150,18 +146,20 @@ def generate_cli_option( """ option_title = key.lower().replace("_", "-") - arguments = get_option_arguments(schema, parameter, key) + arguments = get_option_arguments(parameter, key) # None arguments are usually Enum or nested pydantic structure. # Putting that block in "get_option_arguments" pattern matching can make # the completion crazy (infinite recursivity). if arguments.type is None and parameter.ref: definition = schema.get_definition_from_ref(parameter.ref) - arguments = get_option_arguments(schema, definition, key) + arguments = get_option_arguments(definition, key) + + arguments.required = key in schema.required return click.option( f"--{key_prefix}{option_title}", - **dict(get_option_arguments(schema, parameter, key)) + **dict(arguments) ) -- cgit v1.2.3