pyfcstm.entry.simulate.repl
Enhanced REPL (Read-Eval-Print Loop) for interactive simulation.
This module provides an interactive command-line interface with auto-completion, history, and intelligent suggestions using prompt_toolkit.
AutoSuggestFromCompleter
- class pyfcstm.entry.simulate.repl.AutoSuggestFromCompleter(completer)[source]
Auto-suggest implementation that uses the completer to provide suggestions.
This class provides inline suggestions (gray text) based on the completer’s completions, showing the first matching completion as you type. The suggestion only shows the remaining part of the completion, not the already-typed text.
- Parameters:
completer (SimulationCompleter) – The completer to use for suggestions
- __init__(completer)[source]
Initialize the auto-suggester.
- Parameters:
completer (SimulationCompleter) – The completer to use for suggestions
- get_suggestion(buffer, document)[source]
Get suggestion for the current input.
Returns only the remaining part of the completion that hasn’t been typed yet. For example, if user typed ‘cy’ and completion is ‘cycle’, this returns ‘cle’.
- Parameters:
buffer – The input buffer
document (Document) – The current document
- Returns:
Suggestion or None
- Return type:
Suggestion or None
SimulationREPL
- class pyfcstm.entry.simulate.repl.SimulationREPL(runtime, state_machine=None, use_color: bool = True)[source]
Enhanced REPL for interactive state machine simulation.
This class provides a rich command-line interface with auto-completion, command history, and auto-suggestions using prompt_toolkit.
- Parameters:
runtime (SimulationRuntime) – The simulation runtime instance
use_color (bool, optional) – Whether to use ANSI colors, defaults to True
- Variables:
command_processor (CommandProcessor) – Command processor instance
session (PromptSession) – Prompt toolkit session
- __init__(runtime, state_machine=None, use_color: bool = True)[source]
Initialize the REPL with prompt_toolkit features.
- Parameters:
runtime (SimulationRuntime) – The simulation runtime instance
state_machine (StateMachine, optional) – The state machine model (required for init command)
use_color (bool, optional) – Whether to use ANSI colors, defaults to True
- run()[source]
Run the REPL main loop with prompt_toolkit.
This method runs an infinite loop reading user input with auto-completion and history support until the user exits with /quit or /exit, or sends EOF (Ctrl+D).
Ctrl+C (KeyboardInterrupt) cancels the current input but does not exit. Ctrl+R enables reverse history search.