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:
@ -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()
|
||||
|
@ -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())
|
||||
|
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user