Skip to main content

Reliable and introspectable async CLI action framework.

Project description

⚔️ Falyx

Python License Async-Ready

Falyx is a battle-ready, introspectable CLI framework for building resilient, asynchronous workflows with:

  • ✅ Modular action chaining and rollback
  • 🔁 Built-in retry handling
  • ⚙️ Full lifecycle hooks (before, after, success, error, teardown)
  • 📊 Execution tracing, logging, and introspection
  • 🧙‍♂️ Async-first design with Process support
  • 🧩 Extensible CLI menus and customizable output

Built for developers who value clarity, resilience, and visibility in their terminal workflows.


✨ Why Falyx?

Modern CLI tools deserve the same resilience as production systems. Falyx makes it easy to:

  • Compose workflows using Action, ChainedAction, or ActionGroup
  • Inject the result of one step into the next (last_result)
  • Handle flaky operations with retries and exponential backoff
  • Roll back safely on failure with structured undo logic
  • Add observability with execution timing, result tracking, and hooks
  • Run in both interactive and headless (scriptable) modes
  • Customize output with Rich Tables (grouping, theming, etc.)

🔧 Installation

pip install falyx

Or install from source:

git clone https://github.com/rolandtjr/falyx.git
cd falyx
poetry install

⚡ Quick Example

import asyncio
import random

from falyx import Falyx, Action, ChainedAction

# A flaky async step that fails randomly
async def flaky_step():
    await asyncio.sleep(0.2)
    if random.random() < 0.5:
        raise RuntimeError("Random failure!")
    return "ok"

# Create the actions
step1 = Action(name="step_1", action=flaky_step, retry=True)
step2 = Action(name="step_2", action=flaky_step, retry=True)

# Chain the actions
chain = ChainedAction(name="my_pipeline", actions=[step1, step2])

# Create the CLI menu
falyx = Falyx("🚀 Falyx Demo")
falyx.add_command(
    key="R",
    description="Run My Pipeline",
    action=chain,
    logging_hooks=True,
    preview_before_confirm=True,
    confirm=True,
)

# Entry point
if __name__ == "__main__":
    asyncio.run(falyx.run())
 python simple.py
                                🚀 Falyx Demo

  [R] Run My Pipeline
  [Y] History                                         [Q] Exit

>
 python simple.py run R
Command: 'R'  Run My Pipeline
└──  ChainedAction 'my_pipeline'
    ├──  Action 'step_1'
        Retries: 3x, delay 1.0s, backoff 2.0x
    └──  Action 'step_2'
         Retries: 3x, delay 1.0s, backoff 2.0x
Confirm execution of R  Run My Pipeline (calls `my_pipeline`)  [Y/n] y
[2025-04-15 22:03:57] WARNING   ⚠️ Retry attempt 1/3 failed due to 'Random failure!'.
✅ Result: ['ok', 'ok']

📦 Core Features

  • ✅ Async-native Action, ChainedAction, ActionGroup
  • 🔁 Retry policies + exponential backoff
  • ⛓ Rollbacks on chained failures
  • 🎛️ Headless or interactive CLI with argparse and prompt_toolkit
  • 📊 Built-in execution registry, result tracking, and timing
  • 🧠 Supports ProcessAction for CPU-bound workloads
  • 🧩 Custom Table rendering for CLI menu views
  • 🔍 Hook lifecycle: before, on_success, on_error, after, on_teardown

🔍 Execution Trace

[2025-04-14 10:33:22] DEBUG    [Step 1]  flaky_step()
[2025-04-14 10:33:22] INFO     [Step 1] 🔁 Retrying (1/3) in 1.0s...
[2025-04-14 10:33:23] DEBUG    [Step 1]  Success | Result: ok
[2025-04-14 10:33:23] DEBUG    [My Pipeline]  Result: ['ok', 'ok']

🧱 Core Building Blocks

Action

A single async unit of work. Painless retry support.

ChainedAction

Run tasks in sequence. Supports rollback on failure and context propagation.

ActionGroup

Run tasks in parallel. Useful for fan-out operations like batch API calls.

ProcessAction

Offload CPU-bound work to another process — no extra code needed.

Falyx

Your CLI controller — powers menus, subcommands, history, bottom bars, and more.

ExecutionContext

Tracks metadata, arguments, timing, and results for each action execution.

HookManager

Registers and triggers lifecycle hooks (before, after, on_error, etc.) for actions and commands.


🧠 Design Philosophy

“Like a phalanx: organized, resilient, and reliable.”

Falyx is designed for developers who don’t just want CLI tools to run — they want them to fail meaningfully, recover gracefully, and log clearly.


Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

falyx-0.1.36.tar.gz (68.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

falyx-0.1.36-py3-none-any.whl (91.5 kB view details)

Uploaded Python 3

File details

Details for the file falyx-0.1.36.tar.gz.

File metadata

  • Download URL: falyx-0.1.36.tar.gz
  • Upload date:
  • Size: 68.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.14.2-arch1-1

File hashes

Hashes for falyx-0.1.36.tar.gz
Algorithm Hash digest
SHA256 6e2c73bc436e8b5972a41c11d06715aea42dba77788b258e77221afffada857e
MD5 f3f2139341b1d3721f15010ad74690d8
BLAKE2b-256 7a1e23c6f587cdd5fbcba7e366683a015af6dc07caac95354e2437aed6d3a913

See more details on using hashes here.

File details

Details for the file falyx-0.1.36-py3-none-any.whl.

File metadata

  • Download URL: falyx-0.1.36-py3-none-any.whl
  • Upload date:
  • Size: 91.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.14.2-arch1-1

File hashes

Hashes for falyx-0.1.36-py3-none-any.whl
Algorithm Hash digest
SHA256 e91ac1538ebdf366c3a960b60624f27d2bd079d8e054a7c9de8f2f37ca1cea18
MD5 ad8e06ee35b1de367b7f4c8056c970f0
BLAKE2b-256 3fef0aaa4a768acabb3a2b924c2dd507a9032b50fbece5c7b1b35b57eea816ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page