ReMe/reme_cli/component/flow/cmd_flow.py
2026-04-09 10:38:04 +08:00

18 lines
671 B
Python

"""Command-based flow implementation for parsing and executing operation sequences."""
from .base_flow import BaseFlow
from ..op import BaseOp
class CmdFlow(BaseFlow):
"""A flow class that builds an operation chain from a string expression."""
def __init__(self, flow: str = "", **kwargs):
"""Initialize the command flow with a string-based operation definition."""
super().__init__(**kwargs)
self.flow = flow
assert flow, "add `cmd.flow=<op_flow>` in cmd!"
def _build_flow(self) -> BaseOp:
"""Parse the stored flow expression into a functional operation object."""
return self.parse_expression(self.flow)