Add loading submenus from config or Falyx object, more examples

This commit is contained in:
2025-05-13 23:19:29 -04:00
parent 2bdca72e04
commit bba473047c
9 changed files with 151 additions and 15 deletions

31
examples/run_key.py Normal file
View File

@ -0,0 +1,31 @@
import asyncio
from falyx import Action, Falyx
async def main():
state = {"count": 0}
async def flaky():
if not state["count"]:
state["count"] += 1
print("Flaky step failed, retrying...")
raise RuntimeError("Random failure!")
return "ok"
# Add a command that raises an exception
falyx.add_command(
key="E",
description="Error Command",
action=Action("flaky", flaky),
retry=True,
)
result = await falyx.run_key("E")
print(result)
assert result == "ok"
if __name__ == "__main__":
falyx = Falyx("Headless Recovery Test")
asyncio.run(main())