mirror of
https://github.com/natelandau/obsidian-metadata.git
synced 2025-11-16 17:03:48 -05:00
fix: only ask for valid metadata types when adding new metadata
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user