Skip to content

Tool interface


Tool

Base class for all tools. A tool is an executable that may require special handling to be executed properly.

app property

The Application instance.

format_command abstractmethod

format_command(command: list[str]) -> list[str]

Format a command to be executed by the tool.

Parameters:

Name Type Description Default
command list[str]

The command to format.

required

Returns:

Type Description
list[str]

The formatted command.

env_vars

env_vars() -> dict[str, str]

Returns:

Type Description
dict[str, str]

The environment variables to set for the tool.

run

run(command: list[str], **kwargs: Any) -> int

Equivalent to SubprocessRunner.run with the command formatted by the tool's format_command method and the environment variables set by the tool's env_vars method (if any).

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.run.

capture

capture(command: list[str], **kwargs: Any) -> str

Equivalent to SubprocessRunner.capture with the command formatted by the tool's format_command method and the environment variables set by the tool's env_vars method (if any).

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.capture.

wait

wait(command: list[str], **kwargs: Any) -> None

Equivalent to SubprocessRunner.wait with the command formatted by the tool's format_command method and the environment variables set by the tool's env_vars method (if any).

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.wait.

exit_with

exit_with(command: list[str], **kwargs: Any) -> NoReturn

Equivalent to SubprocessRunner.exit_with with the command formatted by the tool's format_command method and the environment variables set by the tool's env_vars method (if any).

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.exit_with.

attach

attach(command: list[str], **kwargs: Any) -> CompletedProcess

Equivalent to SubprocessRunner.attach with the command formatted by the tool's format_command method and the environment variables set by the tool's env_vars method (if any).

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.attach.

redirect

redirect(command: list[str], **kwargs: Any) -> CompletedProcess

Equivalent to SubprocessRunner.redirect with the command formatted by the tool's format_command method and the environment variables set by the tool's env_vars method (if any).

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.redirect.