Commit eee751a9 authored by Adrian DC's avatar Adrian DC
Browse files

fix: resolve #239: ensure 'NO_COLOR' also avoids questionary colors

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 1863c528
Loading
Loading
Loading
Loading
Loading
+9 −0
Changes for README.md: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -248,6 +248,15 @@ gitlabci-local --settings

---

## Environment available configurations

gitlabci-local uses `colored` for colors outputs and `questionary` for interactive menus.

If colors of both outputs types do not match the terminal's theme,  
an environment variable `NO_COLOR=1` can be defined to disable colors.

---

## Supported .gitlab-ci.yml features

```yml
+4 −1
Changes for gitlabci_local/prints/colors.py: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
#!/usr/bin/env python3

# Modules libraries
from colored import attr, fg
from colored import attr, colored, fg

# Colors class, pylint: disable=too-few-public-methods
class Colors:
@@ -18,3 +18,6 @@ class Colors:

    # Attributes
    ALL = [BOLD, CYAN, GREEN, GREY, RED, RESET, YELLOW, YELLOW_LIGHT]

    # Flags
    ENABLED = colored('').enabled()
+9 −6
Changes for gitlabci_local/prints/themes.py: 9 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -3,16 +3,19 @@
# Modules libraries
from prompt_toolkit.styles.style import Style as prompt_toolkit_styles_Style

# Components
from .colors import Colors

# Themes class, pylint: disable=too-few-public-methods
class Themes:

    # Constants
    BOLD: str = 'bold'
    CYAN: str = '#00FFFF bold'
    DISABLED: str = 'italic'
    GREEN: str = '#00FF00 bold noreverse'
    SELECTED: str = 'bold noreverse'
    YELLOW: str = '#FFFF00 bold'
    BOLD: str = 'bold' if Colors.ENABLED else 'noinherit bold'
    CYAN: str = '#00FFFF bold' if Colors.ENABLED else 'noinherit bold'
    DISABLED: str = 'italic' if Colors.ENABLED else 'noinherit italic'
    GREEN: str = '#00FF00 bold noreverse' if Colors.ENABLED else 'noinherit bold noreverse'
    SELECTED: str = 'bold noreverse' if Colors.ENABLED else 'noinherit bold noreverse'
    YELLOW: str = '#FFFF00 bold' if Colors.ENABLED else 'noinherit bold'

    # Checkbox theme
    CHECKBOX: prompt_toolkit_styles_Style = prompt_toolkit_styles_Style([
+21 −0
Changes for tests/colors/.gitlab-ci.yml: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
image: registry.gitlab.com/adriandc/gitlabci-local/alpine:3

stages:
  - build
  - disabled

'Job 1':
  stage: build
  script:
    - echo 'Job 1'

.template_1:
  before_script:
    - echo 'Template 1 [BEFORE]'

'Job Broken 1':
  stage: disabled
  extends: template_1

'Job Broken 2':
  extends: template_2

tests/colors/test.sh

0 → 100644
+14 −0
Changes for tests/colors/test.sh: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/sh

# Access folder
script_path=$(readlink -f "${0}")
test_path=$(readlink -f "${script_path%/*}")
cd "${test_path}/"

# Configure tests
set -ex

# Run tests
gitlabci-local -H -p
FORCE_COLOR=1 gitlabci-local -H -p
NO_COLOR=1 gitlabci-local -H -p