openpectus.engine.internal_commands

Attributes

logger

Classes

InternalCommandsRegistry

InternalEngineCommand

Base class for internal engine commands.

Module Contents

openpectus.engine.internal_commands.logger
class openpectus.engine.internal_commands.InternalCommandsRegistry(engine)
engine
_command_map: dict[str, Callable[[], InternalEngineCommand]]
_command_spec: dict[str, openpectus.lang.exec.argument_specification.ArgSpec]
_command_instances: dict[str, InternalEngineCommand]
__str__()
Return type:

str

__enter__()
__exit__(exc_type, exc_value, exc_traceback)
_register_commands(engine)
get_running_internal_command()
Return type:

InternalEngineCommand | None

create_internal_command(command_name)
Parameters:

command_name (str)

Return type:

InternalEngineCommand

dispose_command(command_name)
_finalize_instances()

Finalize and dispose all command instances.

get_command_definitions()

Create and return the list of LSP command definitions that specify how command arguments should be parsed.

Return type:

list[openpectus.protocol.models.CommandDefinition]

class openpectus.engine.internal_commands.InternalEngineCommand(name, registry)

Bases: openpectus.engine.commands.EngineCommand

Base class for internal engine commands.

Adds support for long-running commands via a _run() generator method. The tick() base class method implements the state management of these commands.

Parameters:
argument_validation_spec: openpectus.lang.exec.argument_specification.ArgSpec
_registry
_failed = False
has_run = False
run_result: Generator[None, None, None] | None = None
kvargs: dict[str, Any]
validate_arguments(arguments)

Validates the runtime argument string provided to the command against the command’s ArgSpec.

Raises ValueError if the argument is not valid. Otherwise, sets kvargs to the regex groups of the ArgSpec.

Override for custom (non-regex) argument handling.

Parameters:

arguments (str)

abstract _run()

Override to implement the command using a generator style where each yield pauses execution until the next tick (i.e. call to execute()).

Return type:

Generator[None, None, None] | None

fail()
has_failed()
set_complete()
finalize()

Overrides must call super().finalize() and must dispose the command.

tick()
Return type:

None