Overview

Date: 2026-05-11

Time: 15:48

Overview

This is an example script demonstrating FTL2's output and progress control system. It shows how to configure verbosity levels (verbose, quiet, default), use event callbacks for structured event handling, and build custom progress displays. These controls let automation users choose between human-readable output during development and machine-processable events in production scripts.

Usage Patterns

Three output modes controlled via automation() context manager kwargs:


# Default — errors only, no output for successful operations
async with automation() as ftl:
    await ftl.file(path="/tmp/test.txt", state="touch")

# Verbose — shows every operation with timing
async with automation(verbose=True) as ftl:
    await ftl.command(cmd="echo hello")

# Quiet — suppresses all output; check results programmatically
async with automation(quiet=True) as ftl:
    await ftl.file(path="/tmp/test.txt", state="touch")
    success_count = sum(1 for r in ftl.results if r.success)

# Event callback — receive structured dicts per operation
async with automation(on_event=my_callback) as ftl:
    await ftl.command(cmd="echo hello")

# Quiet + events — silent execution with structured capture
async with automation(quiet=True, on_event=events.append) as ftl:
    ...

AutomationContext can also be instantiated directly to inspect output_mode:


ctx = AutomationContext(verbose=True)
print(ctx.output_mode)  # OutputMode enum value

API and Configuration

| Parameter | Type | Effect |

|-----------|------|--------|

| verbose=True | bool | Shows all operations with execution timing |

| quiet=True | bool | Suppresses all console output |

| on_event=callback | callable | Receives event dicts for each module start/complete |

Event dict fields: event ("modulestart" or "modulecomplete"), module, host, success, changed, duration (float, seconds), timestamp.

Result access: ftl.results — list of result objects with .success and .changed attributes, available after operations complete.

Output mode property: ftl.outputmode / context.outputmode — returns the current OutputMode enum value.

Key Behaviors

Relationships