Skip to content

Commit

Permalink
Use rich for confirmation prompts (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skazza94 committed Jan 30, 2024
1 parent 72f1d6f commit 0a93c98
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Kathara/cli/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@

from rich import box
from rich.panel import Panel
from rich.prompt import Confirm
from rich.text import Text
from terminaltables import DoubleTable

from ... import utils
from ...foundation.manager.stats.IMachineStats import IMachineStats
from ...setting.Setting import Setting
from ...trdparty.consolemenu import PromptUtils, Screen
from ...utils import parse_cd_mac_address

FORBIDDEN_TABLE_COLUMNS = ["container_name"]


def confirmation_prompt(prompt_string: str, callback_yes: Callable, callback_no: Callable) -> Any:
prompt_utils = PromptUtils(Screen())
answer = prompt_utils.prompt_for_bilateral_choice(prompt_string, 'y', 'n')

if answer == "n":
answer = Confirm.ask(prompt_string)
if not answer:
return callback_no()

return callback_yes()
Expand Down

0 comments on commit 0a93c98

Please sign in to comment.