color_tools.cli_commands

CLI package for color_tools.

color_tools.cli_commands.handle_name_command(args)[source]

Handle the ‘name’ command - generate descriptive color names.

Parameters:

args (Namespace) – Parsed command-line arguments

Return type:

None

Exits:

0: Success 2: Invalid input

color_tools.cli_commands.handle_validate_command(args)[source]

Handle the ‘validate’ command - verify color name matches hex code.

Parameters:

args (Namespace) – Parsed command-line arguments

Return type:

None

Exits:

0: Color is a match 1: Color is not a match

color_tools.cli_commands.handle_cvd_command(args)[source]

Handle the ‘cvd’ command - simulate or correct color vision deficiency.

Parameters:

args (Namespace) – Parsed command-line arguments

Return type:

None

Exits:

0: Success 2: Invalid input

color_tools.cli_commands.handle_color_command(args, json_path=None)[source]

Handle the ‘color’ command - search and query CSS colors.

Parameters:
  • args (Namespace) – Parsed command-line arguments

  • json_path (Path | str | None) – Optional custom data directory

Return type:

None

Exits:

0: Success 1: Color not found or error 2: Invalid input

color_tools.cli_commands.handle_filament_command(args, json_path=None)[source]

Handle the ‘filament’ command - search and query 3D printing filaments.

Parameters:
  • args (Namespace) – Parsed command-line arguments

  • json_path (Path | str | None) – Optional custom data directory

Return type:

None

Exits:

0: Success 1: Filament not found or error 2: Invalid input

color_tools.cli_commands.handle_convert_command(args)[source]

Handle the ‘convert’ command - convert between color spaces and check gamut.

Parameters:

args (Namespace) – Parsed command-line arguments

Return type:

None

Exits:

0: Success 2: Invalid input

color_tools.cli_commands.handle_image_command(args)[source]

Handle all image processing commands.

color_tools.cli_commands.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.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.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.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.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.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

color_tools.cli_commands.show_override_report(json_dir=None)[source]

Show detailed report of user overrides and exit.

Analyzes user-colors.json and user-filaments.json to show what core data is being overridden, including conflicts by name and RGB values.

Parameters:

json_dir (str | None) – Optional directory containing JSON files. If None, uses package default.

Return type:

None

color_tools.cli_commands.generate_user_hashes(json_dir=None)[source]

Generate .sha256 files for all user data files and exit.

Creates hash files for user/user-colors.json, user/user-filaments.json, and user/user-synonyms.json if they exist.

Parameters:

json_dir (str | None) – Optional directory containing data files. If None, uses package default.

Return type:

None

color_tools.cli_commands.get_available_palettes(json_path=None)[source]

Get list of available palette names from both core and user palettes with color counts.

Parameters:

json_path (Path | str | None) – Optional custom data directory. If None, uses package default.

Return type:

list[tuple[str, int]]

Returns:

Sorted list of tuples (palette_name, color_count). If a palette fails to load, color_count will be -1.

color_tools.cli_commands.handle_verification_flags(args)[source]

Handle all verification flags and early-exit conditions.

Returns True if the program should exit after verification, False otherwise.

Parameters:

args – Parsed command-line arguments from argparse

Returns:

True if program should exit (verification-only mode or early exit flag)

Return type:

bool