Skip to content

Commit a7432c9

Browse files
committed
add: opt in color log output
resolves #275
1 parent e3fcb17 commit a7432c9

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ workflow [`step-summary`][step-summary], and Pull Request reviews (with
4747
4848
Create a new GitHub Actions workflow in your project, e.g. at [.github/workflows/cpp-linter.yml](https://github.com/cpp-linter/cpp-linter-action/blob/main/.github/workflows/cpp-linter.yml)
4949

50+
> [!TIP]
51+
> To enable color output in the workflow logs, set the environment variable `CPP_LINTER_COLOR` to a value of `on` or `true` or `1`.
52+
5053
The content of the file should be in the following format.
5154

5255
```yaml
@@ -56,6 +59,7 @@ The content of the file should be in the following format.
5659
id: linter
5760
env:
5861
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
CPP_LINTER_COLOR: on # off by default
5963
with:
6064
style: 'file' # Use .clang-format config file
6165
tidy-checks: '' # Use .clang-tidy config file

action.yml

+10
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ runs:
269269
source "$GITHUB_ACTION_PATH/venv/bin/activate"
270270
pip install -r "$GITHUB_ACTION_PATH/requirements.txt"
271271
clang-tools -i ${{ inputs.version }} -b
272+
case "${{ env.CPP_LINTER_COLOR }}" in
273+
"true" | "on" | "1")
274+
pip install -r "$GITHUB_ACTION_PATH/color-requirements.txt"
275+
;;
276+
esac
272277
273278
- name: Run cpp-linter (Unix)
274279
id: cpp-linter-unix
@@ -308,6 +313,11 @@ runs:
308313
Invoke-Expression -Command "$env:GITHUB_ACTION_PATH/venv/Scripts/Activate.ps1"
309314
pip install -r "$env:GITHUB_ACTION_PATH/requirements.txt"
310315
clang-tools -i ${{ inputs.version }} -b
316+
$colorEnabled = "true","on","1"
317+
if ( $colorEnabled.contains("${{ env.CPP_LINTER_COLOR }}") )
318+
{
319+
pip install -r "$GITHUB_ACTION_PATH/color-requirements.txt"
320+
}
311321
312322
- name: Run cpp-linter (Windows)
313323
id: cpp-linter-windows

color-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rich==13.9.2

0 commit comments

Comments
 (0)