CLI#

class wattson.cosimulation.cli.cli.CLI(wattson_client: WattsonClient, default_sig_int_handler: Optional = None)#

Bases: object

Methods

__init__

add_handler_class

clear_input_on_interrupt

get_command_str

get_completer

get_handler

Returns the command and a CliCommandHandler for the given command if registered

get_handlers

get_instance

handle_command

Handles the given command

invalid_command

Handles invalid commands

is_blocked

kill

register_command

Alias for register_handler.

register_handler

Registers a new handler for the given command (hierarchy).

run

unknown_command

Handles unknown commands

Attributes

handler_classes

instance

wattson_client

__init__(wattson_client: WattsonClient, default_sig_int_handler: Optional = None)#
get_handler(command: str | List[str]) Tuple[List[str], CliCommandHandler | None]#

Returns the command and a CliCommandHandler for the given command if registered

Parameters:

command (Union[str, List[str]]) – The command to get the handler for

Returns:

The prefix matched for the handler and the assigned Handler, if any

Return type:

Tuple[List[str],Optional[CliCommandHandler]]

handle_command(command: List[str] | str) bool#

Handles the given command

Parameters:

command (Union[List[str], str]) – The command to handle

Returns:

Whether the next command should be handled. False if the CLI should terminate.

Return type:

bool

invalid_command(command: str | List[str])#

Handles invalid commands

Parameters:

command (Union[str, List[str]]) – The invalid command

register_command(command_hierarchy: str | List[str], handler: CliCommandHandler)#

Alias for register_handler.

Parameters:
register_handler(command_hierarchy: str | List[str], handler: CliCommandHandler)#

Registers a new handler for the given command (hierarchy).

Parameters:
  • command_hierarchy (Union[str, List[str]]) – The command or combination of command and subcommand(s)

  • handler (CliCommandHandler) – The handler to assign for the given hierarchy.

unknown_command(command: str | List[str])#

Handles unknown commands

Parameters:

command (Union[str, List[str]]) – The unknown command