- Add comprehensive module docstrings across the codebase for better clarity and documentation. - Refactor Enum classes (e.g., FileType, ConfirmType) to use `_missing_` for built-in coercion from strings. - Add `encoding` attribute to `LoadFileAction`, `SaveFileAction`, and `SelectFileAction` for more flexible file handling. - Enable lazy file loading by default in `SelectFileAction` to improve performance. - Simplify bottom bar toggle behavior: all toggles now use `ctrl+<key>`, eliminating the need for key conflict checks with Falyx commands. - Add `ignore_in_history` attribute to `Command` to refine how `ExecutionRegistry` identifies the last valid result. - Improve History command output: now includes tracebacks when displaying exceptions.
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
# Falyx CLI Framework — (c) 2025 rtj.dev LLC — MIT Licensed
|
|
"""
|
|
Defines structural protocols for advanced Falyx features.
|
|
|
|
These runtime-checkable `Protocol` classes specify the expected interfaces for:
|
|
- Factories that asynchronously return actions
|
|
- Argument parsers used in dynamic command execution
|
|
|
|
Used to support type-safe extensibility and plugin-like behavior without requiring
|
|
explicit base classes.
|
|
|
|
Protocols:
|
|
- ActionFactoryProtocol: Async callable that returns a coroutine yielding a BaseAction.
|
|
- ArgParserProtocol: Callable that accepts CLI-style args and returns (args, kwargs) tuple.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Awaitable, Callable, Protocol, runtime_checkable
|
|
|
|
from falyx.action.base_action import BaseAction
|
|
|
|
|
|
@runtime_checkable
|
|
class ActionFactoryProtocol(Protocol):
|
|
async def __call__(
|
|
self, *args: Any, **kwargs: Any
|
|
) -> Callable[..., Awaitable[BaseAction]]: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class ArgParserProtocol(Protocol):
|
|
def __call__(self, args: list[str]) -> tuple[tuple, dict]: ...
|