Skip to content

Add colors to the --config output#2584

Merged
DL6ER merged 3 commits into
developmentfrom
new/cli_config_colors
Jul 27, 2025
Merged

Add colors to the --config output#2584
DL6ER merged 3 commits into
developmentfrom
new/cli_config_colors

Conversation

@DL6ER

@DL6ER DL6ER commented Jul 25, 2025

Copy link
Copy Markdown
Member

What does this implement/fix?

Add colorful output to CLI if running in an interactive terminal. Config items changed from their default value are now shown in red, similarly to how we do it in the debug log. This makes reading settings much easier, especially if you want to see which debug flags are enabled, e.g.

image

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories development branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

…fig items changed from their default value are now shown in red, similarly to how we do it in the debug log

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER added the CLI label Jul 25, 2025
@DL6ER DL6ER requested a review from a team as a code owner July 25, 2025 17:38
@DL6ER DL6ER requested a review from Copilot July 25, 2025 17:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds colorful output to the CLI --config command to highlight configuration items that have been changed from their default values. Config items that differ from defaults are now shown in red, making it easier to identify active customizations, particularly for debug flags.

  • Adds color constants and CLI color functions to the public API
  • Implements conditional red coloring for non-default config values in CLI output
  • Moves color definitions from implementation file to header for reusability

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/config/cli.c Implements red coloring for config keys that differ from default values
src/args.h Adds color constants and exposes cli_color function for use across modules
src/args.c Makes cli_color function public and moves color definitions to header

Comment thread src/config/cli.c

@yubiuser yubiuser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you amend the pihole-FTL --help text for --config with an explanation what the items in red mean. (Not to confuse users with red=warning/error assumption)

@yubiuser

Copy link
Copy Markdown
Member

Using this branch causes the gravity web update to display this warning

2025-07-26_14-10

@DL6ER

DL6ER commented Jul 26, 2025

Copy link
Copy Markdown
Member Author

Not sure why this is happening, detecting whether the color is to be added (i.e. if it is an interactive shell) seems to work, e.g.:

No color with

echo "$(pihole-FTL --config debug)"

Colorful output with

pihole-FTL --config debug

edit I found the bug in the core component, please try this together with

sudo pihole checkout core tweak/non_interactive_config

pi-hole/pi-hole#6368

@DL6ER DL6ER force-pushed the new/cli_config_colors branch from 74cf674 to 191aaad Compare July 26, 2025 17:54
@DL6ER

DL6ER commented Jul 26, 2025

Copy link
Copy Markdown
Member Author

Latest commit adds

image

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER merged commit b4fc976 into development Jul 27, 2025
18 checks passed
@DL6ER DL6ER deleted the new/cli_config_colors branch July 27, 2025 18:25
@PromoFaux PromoFaux mentioned this pull request Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants