fix: only ask for valid metadata types when adding new metadata

This commit is contained in:
Nathaniel Landau
2023-05-06 14:52:06 -04:00
parent b762c34860
commit ac487db3fd
3 changed files with 25 additions and 21 deletions

View File

@@ -313,23 +313,6 @@ class Questions:
qmark="INPUT |",
).ask()
def ask_area(self) -> MetadataType | str: # pragma: no cover
"""Ask the user for the metadata area to work on.
Returns:
MetadataType: The metadata area to work on.
"""
choices = []
for metadata_type in MetadataType:
choices.append({"name": metadata_type.value, "value": metadata_type})
choices.append(questionary.Separator()) # type: ignore [arg-type]
choices.append({"name": "Cancel", "value": "cancel"})
return self.ask_selection(
choices=choices,
question="Select the type of metadata",
)
def ask_confirm(self, question: str, default: bool = True) -> bool: # pragma: no cover
"""Ask the user to confirm an action.
@@ -445,6 +428,27 @@ class Questions:
question=question,
)
def ask_meta_type(self) -> MetadataType | str: # pragma: no cover
"""Ask the user for the type of metadata to work on.
Returns:
MetadataType: The metadata type
"""
choices = []
for meta_type in MetadataType:
match meta_type:
case MetadataType.ALL | MetadataType.META | MetadataType.KEYS:
continue
case _:
choices.append({"name": meta_type.value, "value": meta_type})
choices.append(questionary.Separator()) # type: ignore [arg-type]
choices.append({"name": "Cancel", "value": "cancel"})
return self.ask_selection(
choices=choices,
question="Select the type of metadata",
)
def ask_new_key(self, question: str = "New key name") -> str: # pragma: no cover
"""Ask the user for a new metadata key.