diff --git a/colorprinter/print_color.py b/colorprinter/print_color.py index 2b72f84..40c351e 100644 --- a/colorprinter/print_color.py +++ b/colorprinter/print_color.py @@ -1,40 +1,14 @@ - -def print_green(*args): - text = "" - for arg in args: - text += str(arg) + " " - print(f"\033[92m{text}\033[0m") - - -def print_red(*args): - text = "" - for arg in args: - text += str(arg) + " " - print(f"\033[91m{text}\033[0m") - - -def print_yellow(*args): - text = "" - for arg in args: - text += str(arg) + " " - print(f"\033[93m{text}\033[0m") - - -def print_blue(*args): - text = "" - for arg in args: - text += str(arg) + " " - print(f"\033[94m{text}\033[0m") - - -def print_purple(*args): - text = "" - for arg in args: - text += str(arg) + " " - print(f"\033[95m{text}\033[0m") - - def choose_color(last_color_index): + """ + Selects the next color in a predefined sequence of colors. + + Args: + last_color_index (int): The index of the last color used. + + Returns: + tuple: A tuple containing the ANSI escape code for the selected color (str) + and the index of the selected color (int). + """ colors = { "blue": "\033[94m", "green": "\033[92m", @@ -47,7 +21,70 @@ def choose_color(last_color_index): color = color_keys[color_index] return colors[color], color_index + +def print_green(*args): + """ + Prints the provided arguments in green. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[92m{text}\033[0m") + + +def print_red(*args): + """ + Prints the provided arguments in red. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[91m{text}\033[0m") + + +def print_yellow(*args): + """ + Prints the provided arguments in yellow. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[93m{text}\033[0m") + + +def print_blue(*args): + """ + Prints the provided arguments in blue. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[94m{text}\033[0m") + + +def print_purple(*args): + """ + Prints the provided arguments in purple. + """ + text = "" + for arg in args: + text += str(arg) + " " + print(f"\033[95m{text}\033[0m") + + def print_rainbow(*args): + """ + Prints the provided arguments in a rainbow of colors. + + Args: + *args: Variable length argument list. Each argument can be a string, list, or dictionary. + - If the argument is a list, each element in the list will be printed in a different color. + - If the argument is a dictionary, each key-value pair will be printed in a different color. + - If the argument is a string or any other type, it will be printed in a different color. + + Returns: + None + """ color_index = -1 text = "" for arg in args: