Add loading submenus from config or Falyx object, more examples
This commit is contained in:
@ -20,3 +20,12 @@ commands:
|
||||
action: menu_demo.menu
|
||||
tags: [menu, demo]
|
||||
help_text: Run a menu demo with multiple options.
|
||||
|
||||
submenus:
|
||||
- key: C
|
||||
description: Process Menu (From Config)
|
||||
config: process.yaml
|
||||
|
||||
- key: U
|
||||
description: Submenu From Python
|
||||
submenu: submenu.submenu
|
||||
|
6
examples/http.yaml
Normal file
6
examples/http.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
commands:
|
||||
- key: T
|
||||
description: HTTP Test
|
||||
action: single_http.http_action
|
||||
tags: [http, demo]
|
||||
help_text: Run HTTP test.
|
11
examples/process.yaml
Normal file
11
examples/process.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
commands:
|
||||
- key: P
|
||||
description: Pipeline Demo
|
||||
action: pipeline_demo.pipeline
|
||||
tags: [pipeline, demo]
|
||||
help_text: Run Demployment Pipeline with retries.
|
||||
|
||||
submenus:
|
||||
- key: C
|
||||
description: HTTP Test (Nested From Config)
|
||||
config: http.yaml
|
31
examples/run_key.py
Normal file
31
examples/run_key.py
Normal 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())
|
14
examples/single_http.py
Normal file
14
examples/single_http.py
Normal file
@ -0,0 +1,14 @@
|
||||
import asyncio
|
||||
|
||||
from falyx.action import HTTPAction
|
||||
|
||||
http_action = HTTPAction(
|
||||
name="Get Example",
|
||||
method="GET",
|
||||
url="https://jsonplaceholder.typicode.com/posts/1",
|
||||
headers={"Accept": "application/json"},
|
||||
retry=True,
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(http_action())
|
Reference in New Issue
Block a user