Add multi selecto to SelectionAction and SelectFileAction, Allow IOActions to receive no input, Rename subpackage falyx.parsers -> falyx.parser, Add default_text to UserInputAction

This commit is contained in:
2025-06-08 12:09:16 -04:00
parent b24079ea7e
commit 53ba6a896a
36 changed files with 373 additions and 80 deletions

View File

@ -6,11 +6,12 @@ from falyx.action.types import FileReturnType
sf = SelectFileAction(
name="select_file",
suffix_filter=".py",
suffix_filter=".yaml",
title="Select a YAML file",
prompt_message="Choose > ",
prompt_message="Choose 2 > ",
return_type=FileReturnType.TEXT,
columns=3,
number_selections=2,
)
flx = Falyx()

View File

@ -1,5 +1,7 @@
import asyncio
from uuid import uuid4
from falyx import Falyx
from falyx.action import SelectionAction
from falyx.selection import SelectionOption
from falyx.signals import CancelSignal
@ -24,7 +26,45 @@ select = SelectionAction(
show_table=True,
)
try:
print(asyncio.run(select()))
except CancelSignal:
print("Selection was cancelled.")
list_selections = [uuid4() for _ in range(10)]
list_select = SelectionAction(
name="Select Deployments",
selections=list_selections,
title="Select Deployments",
columns=3,
prompt_message="Select 3 Deployments > ",
return_type="value",
show_table=True,
number_selections=3,
)
flx = Falyx()
flx.add_command(
key="S",
description="Select a deployment",
action=select,
help_text="Select a deployment from the list",
)
flx.add_command(
key="L",
description="Select deployments",
action=list_select,
help_text="Select multiple deployments from the list",
)
if __name__ == "__main__":
try:
print(asyncio.run(select()))
except CancelSignal:
print("Selection was cancelled.")
try:
print(asyncio.run(list_select()))
except CancelSignal:
print("Selection was cancelled.")
asyncio.run(flx.run())

View File

@ -2,7 +2,7 @@ import asyncio
from uuid import UUID, uuid4
from falyx import Falyx
from falyx.parsers import CommandArgumentParser
from falyx.parser import CommandArgumentParser
flx = Falyx("Test Type Validation")