Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color to results of script output on CLI to increase awareness #158

Open
jcalzad opened this issue Sep 4, 2024 · 0 comments
Open

Add color to results of script output on CLI to increase awareness #158

jcalzad opened this issue Sep 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jcalzad
Copy link

jcalzad commented Sep 4, 2024

(use upvote 👍 for attentions)
Describe the enhancement
Request to colorize results of script tests on CLI. This would draw user awareness to failed tests and in turn, increase chances of remediation steps being taken prior to upgrade if needed.

Current behavior/output
script results print on CLI in native terminal color

Suggested behavior/output
Have results print in color:

Green
DONE = 'DONE'
PASS = 'PASS'

Red
FAIL_O = 'FAIL - OUTAGE WARNING!!'
FAIL_UF = 'FAIL - UPGRADE FAILURE!!'
ERROR = 'ERROR !!'

Yellow
MANUAL = 'MANUAL CHECK REQUIRED'
POST = 'POST UPGRADE CHECK REQUIRED'
NA = 'N/A'

To Reproduce
Sample python2 script to print out color:

from __future__ import print_function

DONE = 'DONE'
PASS = 'PASS'
FAIL_O = 'FAIL - OUTAGE WARNING!!'
FAIL_UF = 'FAIL - UPGRADE FAILURE!!'
ERROR = 'ERROR !!'
MANUAL = 'MANUAL CHECK REQUIRED'
POST = 'POST UPGRADE CHECK REQUIRED'
NA = 'N/A'

# ANSI escape codes for colors
GREEN = '\033[92m'
RED = '\033[91m'
YELLOW = '\033[93m'
ENDC = '\033[0m'

# List of all status items
status_items = [DONE, PASS, FAIL_O, FAIL_UF, ERROR, MANUAL, POST, NA]

# Function to get the colored status
def get_colored_status(item):
    if item == DONE or item == PASS:
        return "{}{}{}".format(GREEN, item, ENDC)
    elif item == FAIL_O or item == FAIL_UF or item == ERROR:
        return "{}{}{}".format(RED, item, ENDC)
    else:
        return "{}{}{}".format(YELLOW, item, ENDC)

# Print all status items with appropriate colors
for item in status_items:
    print(get_colored_status(item))

Additional context
N/A

@jcalzad jcalzad added the enhancement New feature or request label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant