Add PromptMenuAction, add cancel button to SelectionAction, make get_command async, add Action validation and defauilt nargs to None.
This commit is contained in:
@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from prompt_toolkit.formatted_text import FormattedText
|
||||
|
||||
from falyx.action import BaseAction
|
||||
from falyx.signals import BackSignal, QuitSignal
|
||||
from falyx.themes import OneColors
|
||||
@ -26,6 +28,12 @@ class MenuOption:
|
||||
"""Render the menu option for display."""
|
||||
return f"[{OneColors.WHITE}][{key}][/] [{self.style}]{self.description}[/]"
|
||||
|
||||
def render_prompt(self, key: str) -> FormattedText:
|
||||
"""Render the menu option for prompt display."""
|
||||
return FormattedText(
|
||||
[(OneColors.WHITE, f"[{key}] "), (self.style, self.description)]
|
||||
)
|
||||
|
||||
|
||||
class MenuOptionMap(CaseInsensitiveDict):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user