agentcore_cli.utils.command_executor
agentcore_cli.utils.command_executor
¶
Command execution utilities with security validation for AgentCore CLI.
This module provides a centralized utility for executing shell commands with security validation. It ensures that all subprocess calls consistently capture stdout and stderr while maintaining proper error handling and security validation for AgentCore CLI use cases.
The module is designed to be used as a utility for other modules in the AgentCore CLI.
execute_command(cmd, check=False, text=True, log_cmd=True, log_output=True)
¶
Execute a shell command and capture all output with security validation.
This is a centralized utility to ensure all subprocess calls consistently capture stdout and stderr while maintaining proper error handling and security validation for AgentCore CLI use cases.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd
|
Union[list[str], str]
|
Command to execute, either as list of arguments or shell string |
required |
check
|
bool
|
Whether to raise an exception if command fails |
False
|
text
|
bool
|
Whether to decode output as text (vs bytes) |
True
|
log_cmd
|
bool
|
Whether to log the command being executed |
True
|
log_output
|
bool
|
Whether to log command output |
True
|
Returns:
Type | Description |
---|---|
tuple[int, str, str]
|
Tuple[int, str, str]: (return_code, stdout, stderr) |