summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pydanclick/core.py14
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)
)
remember that computers suck.