Module cli_pretty_printing

Source
Expand description

CLI Pretty Printing module for consistent output formatting

§Examples

use ciphey::cli_pretty_printing::{success, warning};

// Print a success message
let success_msg = success("Operation completed successfully");
assert!(!success_msg.is_empty());

// Print a warning message
let warning_msg = warning("Please check your input");
assert!(!warning_msg.is_empty());

CLI Pretty Printing Module

This module provides a unified interface for all CLI output formatting in ciphey. By centralising all print statements here, we ensure:

  • Consistent visual appearance across the application
  • Standardised color schemes and formatting
  • Proper handling of API mode vs CLI mode
  • Centralised error message formatting

§Color Scheme

The module uses a configurable color scheme with roles:

  • Informational: General information and status updates
  • Warning: Non-critical warnings and cautions
  • Success: Successful operations and confirmations
  • Question: Interactive prompts and user queries
  • Statement: Standard output and neutral messages

§Usage

use ciphey::cli_pretty_printing::{success, warning};

// Print a success message
println!("{}", success("Operation completed successfully"));

// Print a warning message
println!("{}", warning("Please check your input"));

Functions§

countdown_until_program_ends
Updates the user on decoding progress with a countdown timer.
decoded_how_many_times
Prints the number of decoding attempts performed.
display_top_results
Display all plaintext results collected by WaitAthena
failed_to_decode
Prints a failure message when decoding was unsuccessful.
human_checker_check
Prompts the user to verify potential plaintext during human checking.
panic_failure_both_input_and_fail_provided
Handles the error case of receiving both file and text input.
panic_failure_no_input_provided
Handles the error case of receiving no input.
parse_rgb
Parse RGB string in format “r,g,b” to RGB values.
program_exiting_successful_decoding
Prints the final output of a successful decoding operation.
return_early_because_input_text_is_plaintext
Indicates that the input is already plaintext.
statement
Colors text based on its role, defaulting to statement color if no role is specified.
success
Colors text using the success color from config.
warning
Colors text using the warning color from config.
warning_unknown_config_key
Warns about unknown configuration keys.