From e3e4ed967c8aea8e21752f07d7f3626028393b3e Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Wed, 17 Jul 2024 23:18:54 +0200 Subject: [PATCH] Colorize terminal output --- .github/workflows/main.yml | 7 ++++++- scripts.py | 16 ++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82c8bc7..0cdba66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,11 +68,14 @@ jobs: - name: Print some build-specific variables shell: bash - run: scripts/print_build_variables.sh # bash -x scripts/print_build_variables.sh for printing commands + run: | + export TERM=xterm-color + scripts/print_build_variables.sh # bash -x scripts/print_build_variables.sh for printing commands - name: Create scripts, CFML and pyCFML directories shell: bash run: | + export TERM=xterm-color scripts/create_cfml_repo_dir.sh scripts/create_cfml_build_dir.sh scripts/create_cfml_dist_dir.sh @@ -87,6 +90,7 @@ jobs: - name: Build CFML modules shell: bash run: | + export TERM=xterm-color scripts/rename_global_deps_file.sh scripts/build_cfml_modules_obj.sh scripts/delete_renamed_global_deps_file.sh @@ -108,6 +112,7 @@ jobs: (runner.os != 'Windows' || matrix.toolchain.exe != 'ifx') shell: bash run: | + export TERM=xterm-color scripts/build_cfml_test_programs.sh scripts/copy_cfml_test_programs_to_tests_dir.sh scripts/run_cfml_functional_tests_no_benchmarks.sh diff --git a/scripts.py b/scripts.py index 7fed82d..ddf8985 100644 --- a/scripts.py +++ b/scripts.py @@ -11,6 +11,10 @@ global ARGS global CONFIG +BLUE = '\\033[0;34m' +BOLD_GREEN = '\\033[1;32m' +COLOR_OFF = '\\033[0m' + def _github_actions(): if 'GITHUB_ACTIONS' in os.environ: @@ -42,7 +46,7 @@ def _main_script_path(): return path def _echo_msg(msg: str): - return f'echo ":::::: {msg}"' + return f'echo "{BLUE}:::::: {msg}{COLOR_OFF}"' def _echo_progress_msg(current: int, total: int, msg: str): progress = _compiling_progress(current, total) @@ -50,13 +54,13 @@ def _echo_progress_msg(current: int, total: int, msg: str): return _echo_msg(msg) def _echo_header(msg: str): - msg = f':::::: {msg} ::::::' - sep = ':' * len(msg) + msg = f'{BOLD_GREEN}:::::: {msg} ::::::{COLOR_OFF}' + sep = ':' * (len(msg) - len(f'{BOLD_GREEN}') - len(f'{COLOR_OFF}')) lines = [] lines.append(f'echo ""') - lines.append(f'echo "{sep}"') - lines.append(f'echo "{msg}"') - lines.append(f'echo "{sep}"') + lines.append(f'echo "{BOLD_GREEN}{sep}{COLOR_OFF}"') + lines.append(f'echo "{BOLD_GREEN}{msg}{COLOR_OFF}"') + lines.append(f'echo "{BOLD_GREEN}{sep}{COLOR_OFF}"') return lines def _processor():