cli_utils¶
Utility Functions for AWS CDK CLI Command Processing
This module provides a set of utility classes and functions for handling AWS CDK CLI command arguments, execution contexts, and environment management.
- class cdk_mate.cli.cli_utils.BaseArgType[source]¶
Base class for CLI argument type processors.
Defines the interface for processing different types of CLI arguments when building command lines for AWS CDK operations.
- process(name: str, value: Any, args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- class cdk_mate.cli.cli_utils.PositionalArg[source]¶
Process a positional argument for CLI commands.
Example:
name = "id" value = "my-stack" # will be encoded as "my-stack"
- process(name: str, value: Any, args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- class cdk_mate.cli.cli_utils.ValueArg[source]¶
Process a standard value argument for CLI commands.
Example:
name = "stack" value = "my-stack" # will be encoded as "--stack my-stack"
- process(name: str, value: Any, args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- class cdk_mate.cli.cli_utils.BoolArg[source]¶
Process a boolean argument for CLI commands.
Example:
name = "help" value = True # will be encoded as "--help"
- process(name: str, value: Literal['OPT'] | bool, args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- class cdk_mate.cli.cli_utils.KeyValueArg[source]¶
Process a key-value pair argument for CLI commands.
Example:
name = "parameter" value = {"key1": "value1", "key2": "value2"} # will be encoded as "--parameter key1=value1 --parameter key2=value2"
- process(name: str, value: Literal['OPT'] | dict[str, str], args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- class cdk_mate.cli.cli_utils.ArrayArg[source]¶
Process array-type arguments for CLI commands.
Example:
name = "plugin" value = ["plugin1", "plugin2"] # will be encoded as "--plugin plugin1 --plugin plugin2"
- process(name: str, value: Literal['OPT'] | list[str], args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- class cdk_mate.cli.cli_utils.CountArg[source]¶
Process count-based arguments for CLI commands.
Example:
name = "verbose" value = 2 # will be encoded as "--verbose --verbose"
- process(name: str, value: Literal['OPT'] | int, args: list[str])[source]¶
Process an argument for CLI commands.
- Parameters:
name – The name of the argument (without ‘–’ prefix)
value – The value of the argument, can be NOTHING or any value
args – The list of arguments to append the processed argument to
- Returns:
None, modifies the args list in-place
- cdk_mate.cli.cli_utils.run_cmd_v1(args: list[str]) CompletedProcess[source]¶
Run a terminal command using subprocess with standard output.
- cdk_mate.cli.cli_utils.run_cmd_v2(args: list[str], show_output: bool = True) CompletedProcess[source]¶
Run a terminal command with advanced output handling.
- cdk_mate.cli.cli_utils.run_cmd(args: list[str]) CompletedProcess¶
Run a terminal command using subprocess with standard output.
- cdk_mate.cli.cli_utils.run_cdk_command(args: list[str], bsm: BotoSesManager | None = None, dir_cdk: T_PATH_ARG | None = None) CompletedProcess[source]¶
Execute an AWS CDK command with optional AWS session and directory context.
- Parameters:
args – List of CDK command arguments to execute
bsm – Optional Boto Session Manager for AWS credentials and context
dir_cdk – Optional directory path for executing the CDK command
- Raises:
subprocess.CalledProcessError – If the command execution fails
- Returns:
Completed process result from subprocess