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.