Make auto_args default fallback, integrate io_actions with argument parsing

This commit is contained in:
2025-05-19 20:03:04 -04:00
parent 4fa6e3bf1f
commit 3c0a81359c
16 changed files with 125 additions and 87 deletions

View File

@ -24,7 +24,6 @@ cmd = Command(
key="G",
description="Greet someone with multiple variations.",
action=group,
auto_args=True,
arg_metadata={
"name": {
"help": "The name of the person to greet.",

View File

@ -1,14 +1,18 @@
import asyncio
from falyx import Action, Falyx
from falyx import Action, ChainedAction, Falyx
from falyx.utils import setup_logging
setup_logging()
async def deploy(service: str, region: str = "us-east-1", verbose: bool = False):
async def deploy(service: str, region: str = "us-east-1", verbose: bool = False) -> str:
if verbose:
print(f"Deploying {service} to {region}...")
await asyncio.sleep(2)
if verbose:
print(f"{service} deployed successfully!")
return f"{service} deployed to {region}"
flx = Falyx("Deployment CLI")
@ -21,7 +25,6 @@ flx.add_command(
name="deploy_service",
action=deploy,
),
auto_args=True,
arg_metadata={
"service": "Service name",
"region": {"help": "Deployment region", "choices": ["us-east-1", "us-west-2"]},
@ -29,4 +32,23 @@ flx.add_command(
},
)
deploy_chain = ChainedAction(
name="DeployChain",
actions=[
Action(name="deploy_service", action=deploy),
Action(
name="notify",
action=lambda last_result: print(f"Notification: {last_result}"),
),
],
auto_inject=True,
)
flx.add_command(
key="N",
aliases=["notify"],
description="Deploy a service and notify.",
action=deploy_chain,
)
asyncio.run(flx.run())