color_tools.cli_commands.utils

Utility functions for CLI argument parsing and validation.

Helper functions used across CLI command handlers to reduce duplication.

color_tools.cli_commands.utils.validate_color_input_exclusivity(args)[source]

Validate that –value and –hex are mutually exclusive.

Parameters:

args (Namespace) – Parsed command-line arguments

Raises:

SystemExit – If both –value and –hex are specified

Return type:

None

color_tools.cli_commands.utils.get_rgb_from_args(args)[source]

Extract RGB tuple from either –value or –hex arguments.

Parameters:

args (Namespace) – Parsed command-line arguments with either ‘value’ or ‘hex’ attribute

Return type:

tuple[int, int, int]

Returns:

RGB tuple (r, g, b) with values 0-255

Raises:

SystemExit – If neither –value nor –hex is provided, or if hex is invalid

color_tools.cli_commands.utils.parse_hex_or_exit(hex_string)[source]

Parse a hex color string into RGB values, exiting on error.

Parameters:

hex_string (str) – Hex color string (“#FF0000”, “FF0000”, “#24c”, “24c”)

Return type:

tuple[int, int, int]

Returns:

RGB tuple (r, g, b) with values 0-255

Raises:

SystemExit – If hex string is invalid

color_tools.cli_commands.utils.is_valid_lab(lab_tuple)[source]

Validate if a Lab tuple is within the standard 8-bit Lab range. Lab tuple format: (L*, a*, b*)

Parameters:

lab_tuple – Tuple or list of 3 numeric values

Return type:

bool

Returns:

True if valid Lab values, False otherwise

color_tools.cli_commands.utils.is_valid_lch(lch_tuple)[source]

Validate if an LCh(ab) tuple is within the standard range. LCh tuple format: (L*, C*, h°)

Parameters:

lch_tuple – Tuple or list of 3 numeric values

Return type:

bool

Returns:

True if valid LCh values, False otherwise

color_tools.cli_commands.utils.get_program_name()[source]

Determine the proper program name based on how we were invoked.

Return type:

str

Returns:

Program name to display in help text