diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-10-08 14:21:03 +0200 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-10-08 14:21:03 +0200 |
commit | bbe43f4c8fa26e752cb0921b642d602ff14235ed (patch) | |
tree | 5f04570f9077e33772df7490ed47d1b741d4ed4f | |
parent | 037ab915bd455cccf46391f02f61949e5c84f1c3 (diff) | |
download | pydanclick-bbe43f4c8fa26e752cb0921b642d602ff14235ed.tar.gz |
fixup! wip: saturday fixup
-rw-r--r-- | pydanclick/core.py | 14 |
1 files 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) ) |