Skip to content

Commit

Permalink
Colorize terminal output
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSazonov committed Jul 17, 2024
1 parent 758cd40 commit e3e4ed9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -42,21 +46,21 @@ 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)
msg = f"[{progress:>3}%] {msg}"
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():
Expand Down

0 comments on commit e3e4ed9

Please sign in to comment.