plexus.cli.procedure.lua_dsl.primitives.control module
Control Primitives - Flow control and termination.
Provides: - Iterations.current() - Get current iteration number - Iterations.exceeded(max) - Check if exceeded max iterations - Stop.requested() - Check if stop was requested - Stop.reason() - Get stop reason - Stop.success() - Check if stop was successful
- class plexus.cli.procedure.lua_dsl.primitives.control.IterationsPrimitive
Bases:
objectTracks iteration count for procedure execution.
Provides safety limits and iteration-based control flow.
Initialize iteration counter.
- __init__()
Initialize iteration counter.
- current() int
Get the current iteration number.
- Returns:
Current iteration count (0-indexed)
- Example (Lua):
local iter = Iterations.current() Log.info(“Iteration: “ .. iter)
- exceeded(max_iterations: int) bool
Check if current iteration has exceeded the maximum.
- Args:
max_iterations: Maximum allowed iterations
- Returns:
True if current iteration >= max_iterations
- Example (Lua):
- if Iterations.exceeded(100) then
return {success = false, reason = “Max iterations exceeded”}
end
- increment() int
Increment the iteration counter.
- Returns:
New iteration count
Note: This is called internally by the runtime, not from Lua
- reset() None
Reset iteration counter (mainly for testing).
- class plexus.cli.procedure.lua_dsl.primitives.control.StopPrimitive
Bases:
objectManages procedure termination state.
Tracks when a stop was requested and the reason/success status.
Initialize stop state.
- __init__()
Initialize stop state.
- reason() str | None
Get the reason for stopping.
- Returns:
Stop reason string or None if not stopped
- Example (Lua):
- if Stop.requested() then
Log.info(“Stopped because: “ .. Stop.reason())
end
- request(reason: str, success: bool = True) None
Request a stop (called by tools or runtime).
- Args:
reason: Reason for stopping success: Whether this is a successful completion
Note: This is called internally, not from Lua
- requested() bool
Check if a stop was requested.
- Returns:
True if stop was requested
- Example (Lua):
- if Stop.requested() then
return {success = true, message = “Procedure stopped”}
end
- reset() None
Reset stop state (mainly for testing).
- success() bool
Check if the stop was due to successful completion.
- Returns:
True if stopped successfully, False if stopped due to error
- Example (Lua):
- if Stop.requested() and Stop.success() then
return {success = true}
- else
return {success = false}
end