Skip to content

Add no-color support for atmos #1227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

samtholiya
Copy link
Collaborator

@samtholiya samtholiya commented Apr 30, 2025

what

  • We are adding support for no color output for atmos

why

  • Customer having custom terminal find it difficult to look at the content. Having no color option helps customer to have a visible output

references

Summary by CodeRabbit

  • New Features

    • Added a global --no-color flag to disable colored output in logs and terminal display.
    • Introduced a no_color configuration option with environment variable support (ATMOS_NO_COLOR, NO_COLOR).
  • Bug Fixes

    • Fixed removal of ANSI color codes from logs and markdown rendering when color output is disabled.
  • Documentation

    • Updated CLI help texts and configuration docs to include the new no_color option and flag usage.
  • Tests

    • Added tests validating the --no-color flag, configuration parsing, and markdown rendering without color.
    • Included new snapshot tests and support command test cases.
  • Refactor

    • Replaced previous color-related configuration fields with the new no_color setting for clarity and consistency.

@samtholiya samtholiya added the minor New features that do not break anything label Apr 30, 2025
@github-actions github-actions bot added size/m and removed size/s labels May 1, 2025
Copy link

codecov bot commented May 1, 2025

Codecov Report

Attention: Patch coverage is 75.36232% with 17 lines in your changes missing coverage. Please review.

Project coverage is 34.68%. Comparing base (f26dfe1) to head (efd3bf7).

Files with missing lines Patch % Lines
pkg/ui/markdown/renderer.go 75.00% 8 Missing and 4 partials ⚠️
pkg/config/config.go 40.00% 2 Missing and 1 partial ⚠️
cmd/validate_editorconfig.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1227      +/-   ##
==========================================
+ Coverage   33.56%   34.68%   +1.11%     
==========================================
  Files         226      226              
  Lines       24219    24257      +38     
==========================================
+ Hits         8130     8414     +284     
+ Misses      14875    14605     -270     
- Partials     1214     1238      +24     
Flag Coverage Δ
unittests 34.68% <75.36%> (+1.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtholiya samtholiya force-pushed the feature/dev-3177--no-color-should-be-a-global-flag branch from d1297fb to 14534fb Compare May 1, 2025 15:52
@samtholiya samtholiya force-pushed the feature/dev-3177--no-color-should-be-a-global-flag branch from 00c0e40 to 131249b Compare May 4, 2025 17:56
@@ -1,35 +0,0 @@
package cmd

import (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For some reason this test does not work in our windows workflow after our update.
I tried to check in my windows machine and this test works. Suggesting some strange issue with the worker windows version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the test to the yaml.

Copy link
Member

@osterman osterman May 5, 2025

Choose a reason for hiding this comment

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

Why add to yaml? That doesn’t increase or count towards test coverage and deleting it reduces test coverage.

Copy link
Member

Choose a reason for hiding this comment

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

This is the most basic of tests, so we can just reimplement if it is wrong.

Copy link
Member

Choose a reason for hiding this comment

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

For example, look at how you are implementing the tests for color. You are taking a different approach than what we see in this test. Maybe use the same approach.

Copy link
Collaborator Author

@samtholiya samtholiya May 5, 2025

Choose a reason for hiding this comment

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

I already tried reimplementing it in different ways.
Just not sure why this is happening here.
The issue is outputting to the pipe buffer that we create.
But i am not sure why only this test case out of the many we have.

While i understand your perspective that this does not add coverage in yaml mode.

It covers only one line. So not sure worth the effort in debugging it for long.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 5, 2025
Copy link
Contributor

coderabbitai bot commented May 5, 2025

📝 Walkthrough

Walkthrough

This update introduces a new global --no-color flag and supporting configuration options to disable colored output in CLI logs and terminal rendering. It refactors configuration schemas, updates documentation, modifies tests and snapshots to reflect the new flag, and centralizes color control through the no_color setting across CLI, environment variables, and configuration files.

Changes

File(s) / Group Change Summary
cmd/root.go, pkg/config/config.go, pkg/config/load.go, pkg/config/default.go Added support for a global --no-color flag, updated config loading to support no_color via CLI, env, or config, and removed old color defaults.
cmd/root_test.go, pkg/config/config_test.go, pkg/ui/markdown/renderer_test.go Added/updated tests to verify no-color behavior and flag parsing for CLI and markdown rendering.
cmd/validate_editorconfig.go Removed local --no-color flag, now handled globally; updated logic to use new config structure.
pkg/schema/schema.go Replaced colors and color fields with a single no_color boolean in config schema structs.
pkg/ui/markdown/renderer.go Refactored renderer to respect no_color config, added TTY function pointers, removed RenderWithStyle.
tests/snapshots/*.golden Updated CLI help and config output snapshots to reflect new --no-color flag and schema changes.
tests/test-cases/empty-dir.yaml, tests/snapshots/TestCLICommands_atmos_support.stdout.golden Added new test and snapshot for the atmos support command.
website/docs/cli/configuration/configuration.mdx, website/docs/cli/configuration/terminal.mdx Updated documentation to describe no_color config and usage, replacing previous color options.
cmd/support_test.go Removed obsolete test for the support command.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Config
    participant Logger
    participant Renderer

    User->>CLI: Run command with/without --no-color
    CLI->>Config: Load config, parse env/flags
    Config->>CLI: Provide no_color setting
    CLI->>Logger: Setup logger (disable color if no_color)
    CLI->>Renderer: Initialize renderer (disable color if no_color)
    CLI->>User: Output (colored or plain, per config)
Loading

Possibly related PRs

  • cloudposse/atmos#1102: Removes the colored package and its initialization, which is related to CLI color handling, similar in scope to this PR's introduction of explicit no-color support.

Suggested reviewers

  • osterman
  • aknysh

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39bbe6c and efd3bf7.

📒 Files selected for processing (7)
  • pkg/config/default.go (0 hunks)
  • pkg/config/load.go (2 hunks)
  • pkg/schema/schema.go (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden (2 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden (0 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_config_imports.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_configuration.stdout.golden (0 hunks)
💤 Files with no reviewable changes (3)
  • tests/snapshots/TestCLICommands_atmos_describe_configuration.stdout.golden
  • pkg/config/default.go
  • tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden
✅ Files skipped from review due to trivial changes (1)
  • pkg/schema/schema.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/snapshots/TestCLICommands_atmos_describe_config_imports.stdout.golden
  • tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden
  • pkg/config/load.go
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Analyze (go)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Summary
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
pkg/ui/markdown/renderer.go (1)

140-147: ⚠️ Potential issue

Use the injected TTY helpers everywhere, not the global ones

Inside the rendering loop you fall back to term.IsTTYSupportForStdout(), bypassing the injected r.isTTYSupportForStdout that was introduced precisely to make TTY detection replaceable (e.g. for tests).
This breaks the abstraction and makes the behaviour harder to stub in unit tests.

- if strings.HasPrefix(trimmed, "$") && term.IsTTYSupportForStdout() {
+ if strings.HasPrefix(trimmed, "$") && r.isTTYSupportForStdout() {

A quick replace keeps the logic intact while preserving testability.

🧹 Nitpick comments (4)
tests/test-cases/empty-dir.yaml (1)

17-27: Add basic integration test for the support command
This new test ensures the atmos support command executes successfully. Consider adding expected stdout patterns or snapshots to validate the output content in future iterations.

cmd/root_test.go (1)

12-37: Good test coverage for no-color functionality.

The test correctly verifies that setting the NO_COLOR environment variable disables color output in logs. This ensures the feature works as expected.

There's a commented-out line at line 14 that appears to be duplicated by line 16 and could be removed:

-	// t.Setenv("NO_COLOR", "1")
pkg/config/config_test.go (1)

441-488: Comprehensive testing of no-color flag combinations.

The test cases effectively verify that the --no-color flag is properly propagated to the configuration, including testing various combinations with log level settings. I particularly like the inclusion of the explicit false case (--no-color=false).

Note that the variable name expectetdNoColor has a typo and should be expectedNoColor, but it doesn't affect functionality.

-		expectetdNoColor bool
+		expectedNoColor bool
pkg/ui/markdown/renderer.go (1)

80-109: Renderer re-creation on every call hurts performance

RenderWithoutWordWrap spins up a brand-new Glamour renderer every single invocation.
For large documentation generation loops this is needlessly expensive; the renderer can be prepared once (at construction time) with word-wrap 0 and reused, or at minimum cached behind a sync.Once.

If immutability of r.renderer is desired, consider adding a small cache:

// inside Renderer
asciiNoWrap *glamour.TermRenderer // lazily initialised

and populate it only the first time the path is taken.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 91-92: pkg/ui/markdown/renderer.go#L91-L92
Added lines #L91 - L92 were not covered by tests


[warning] 97-98: pkg/ui/markdown/renderer.go#L97-L98
Added lines #L97 - L98 were not covered by tests


[warning] 107-108: pkg/ui/markdown/renderer.go#L107-L108
Added lines #L107 - L108 were not covered by tests

🪛 GitHub Check: golangci-lint

[warning] 83-83:
if r.atmosConfig.Settings.Terminal.NoColor has complex nested blocks (complexity: 4)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c87cd51 and 39bbe6c.

📒 Files selected for processing (45)
  • cmd/root.go (3 hunks)
  • cmd/root_test.go (1 hunks)
  • cmd/support_test.go (0 hunks)
  • cmd/validate_editorconfig.go (1 hunks)
  • pkg/config/config.go (1 hunks)
  • pkg/config/config_test.go (1 hunks)
  • pkg/config/default.go (0 hunks)
  • pkg/config/load.go (2 hunks)
  • pkg/schema/schema.go (1 hunks)
  • pkg/ui/markdown/renderer.go (4 hunks)
  • pkg/ui/markdown/renderer_test.go (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Command_Line_Flag.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Environment_Variable.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_log_file_in_env_should_be_priortized_over_config.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_log_file_in_flag_should_be_priortized_over_env_and_config.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_log_level_in_env_should_be_priortized_over_config.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_log_level_in_flag_should_be_priortized_over_env_and_config.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden (2 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden (0 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_config_imports.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_describe_configuration.stdout.golden (0 hunks)
  • tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_support.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (1 hunks)
  • tests/test-cases/empty-dir.yaml (1 hunks)
  • website/docs/cli/configuration/configuration.mdx (1 hunks)
  • website/docs/cli/configuration/terminal.mdx (2 hunks)
💤 Files with no reviewable changes (4)
  • tests/snapshots/TestCLICommands_atmos_describe_configuration.stdout.golden
  • tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden
  • pkg/config/default.go
  • cmd/support_test.go
🧰 Additional context used
🧠 Learnings (2)
pkg/config/load.go (1)
Learnt from: osterman
PR: cloudposse/atmos#1202
File: pkg/utils/yaml_func_exec.go:104-104
Timestamp: 2025-04-23T15:02:50.246Z
Learning: In the Atmos codebase, direct calls to `os.Getenv` should be avoided. Instead, use `viper.BindEnv` for environment variable access. This provides a consistent approach to configuration management across the codebase.
cmd/validate_editorconfig.go (1)
Learnt from: Listener430
PR: cloudposse/atmos#844
File: cmd/helmfile.go:37-37
Timestamp: 2024-12-11T18:40:12.808Z
Learning: In the atmos project, `cliConfig` is initialized within the `cmd` package in `root.go` and can be used in other command files.
🧬 Code Graph Analysis (4)
pkg/config/config.go (1)
pkg/schema/schema.go (2)
  • Settings (716-720)
  • Terminal (188-194)
cmd/validate_editorconfig.go (1)
pkg/schema/schema.go (1)
  • Terminal (188-194)
pkg/config/config_test.go (1)
pkg/schema/schema.go (2)
  • AtmosConfiguration (13-45)
  • Logs (304-307)
pkg/ui/markdown/renderer.go (3)
pkg/schema/schema.go (3)
  • AtmosConfiguration (13-45)
  • Settings (716-720)
  • Terminal (188-194)
internal/tui/templates/term/term_writer.go (2)
  • IsTTYSupportForStdout (83-87)
  • IsTTYSupportForStderr (90-94)
pkg/ui/markdown/styles.go (1)
  • GetDefaultStyle (24-90)
🪛 GitHub Check: codecov/patch
pkg/config/config.go

[warning] 83-84: pkg/config/config.go#L83-L84
Added lines #L83 - L84 were not covered by tests

cmd/validate_editorconfig.go

[warning] 121-121: cmd/validate_editorconfig.go#L121
Added line #L121 was not covered by tests

pkg/ui/markdown/renderer.go

[warning] 50-51: pkg/ui/markdown/renderer.go#L50-L51
Added lines #L50 - L51 were not covered by tests


[warning] 91-92: pkg/ui/markdown/renderer.go#L91-L92
Added lines #L91 - L92 were not covered by tests


[warning] 97-98: pkg/ui/markdown/renderer.go#L97-L98
Added lines #L97 - L98 were not covered by tests


[warning] 107-108: pkg/ui/markdown/renderer.go#L107-L108
Added lines #L107 - L108 were not covered by tests

🪛 GitHub Check: golangci-lint
pkg/ui/markdown/renderer.go

[warning] 83-83:
if r.atmosConfig.Settings.Terminal.NoColor has complex nested blocks (complexity: 4)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (39)
tests/snapshots/TestCLICommands_Valid_Log_Level_in_Command_Line_Flag.stdout.golden (1)

2-2: Snapshot environment label updated
The platform identifier was changed from darwin/arm64 to linux/amd64 to match the test environment. No functional changes here.

tests/snapshots/TestCLICommands_Valid_log_level_in_env_should_be_priortized_over_config.stdout.golden (1)

2-2: Snapshot environment label updated
This updates the platform label to linux/amd64, aligning with the environment where tests ran. No logic affected.

tests/snapshots/TestCLICommands_Valid_Log_Level_in_Environment_Variable.stdout.golden (1)

2-2: Snapshot environment label updated
Platform identifier updated to linux/amd64 for consistency with the CI environment. No functional change.

tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stdout.golden (1)

2-2: Snapshot environment label updated
Changed to linux/amd64 to reflect the testing environment. Functional behavior remains unchanged.

tests/snapshots/TestCLICommands_Valid_log_level_in_flag_should_be_priortized_over_env_and_config.stdout.golden (1)

2-2: Snapshot environment label updated
Updated the platform tag to linux/amd64, matching the environment. No logic modification.

tests/snapshots/TestCLICommands_Valid_log_file_in_env_should_be_priortized_over_config.stdout.golden (1)

7-7: Update snapshot platform identifier
The change from “darwin/arm64” to “linux/amd64” aligns with the current CI environment and has no impact on functionality.

tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden (1)

111-113: Add global --no-color flag to help output
The new flag is correctly placed under Global Flags with consistent indentation and description, matching the PR’s goal of disabling colored output.

tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden (1)

49-49: Add global --no-color flag to apply help
The flag is properly integrated into the Global Flags section and mirrors the formatting in other commands.

tests/snapshots/TestCLICommands_Valid_log_file_in_flag_should_be_priortized_over_env_and_config.stdout.golden (1)

7-7: Update snapshot platform identifier
Switching to “linux/amd64” reflects the testing environment update and does not affect functionality.

tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden (1)

37-37: Add global --no-color flag to about help
Placement under Global Flags is consistent with other help outputs, ensuring uniform documentation of the new flag.

tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden (1)

56-56: Approved: Snapshot updated for atmos helmfile --help
The new --no-color global flag is present with (default false) as expected.

tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden (1)

45-45: Approved: Snapshot updated for atmos atlantis --help
The --no-color global flag appears correctly with default false.

tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden (1)

45-45: Approved: Snapshot updated for atmos atlantis help
The global --no-color option is correctly shown with (default false).

tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden (1)

38-38: Approved: Snapshot updated for atmos helmfile apply --help
The --no-color flag is now listed under Global Flags with default false.

tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden (1)

56-56: Approved: Snapshot updated for atmos helmfile help
The global --no-color flag appears as intended with (default false).

tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden (1)

38-39: LGTM! No-color global flag is properly implemented.

The --no-color flag has been added as a global flag with clear documentation and default value (false), addressing the accessibility needs mentioned in the PR objectives.

tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden (1)

111-112: Global flag consistently applied to terraform command.

The --no-color flag is consistently documented with the same description and default value as in other commands, maintaining a unified CLI interface.

tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden (1)

49-50: No-color flag correctly added to terraform apply subcommand.

The global --no-color flag is properly documented in the terraform apply help output, ensuring users know about this accessibility option when viewing subcommand help.

tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden (1)

48-49: No-color flag correctly implemented in atlantis command.

The global --no-color flag has been consistently applied to the atlantis generate command help output. This completes the implementation across all reviewed CLI commands.

tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden (1)

48-49: New global flag looks good.

The --no-color flag addition is consistent with the PR objective to provide a way to disable colored output. This feature will help users with custom terminals who find colored output difficult to read.

tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden (1)

85-86: Global flag placement is consistent.

The --no-color flag appears in the correct section under Global Flags with appropriate formatting and consistent description.

tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden (1)

85-86: Flag description is clear and properly positioned.

The --no-color flag has been properly added to the Global Flags section with a clear description that aligns with its purpose.

tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden (1)

116-117: Global flag consistently implemented.

The --no-color flag has been properly added to the Terraform command help output, maintaining consistency across all command help displays.

tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (1)

73-73: Include global --no-color flag in help snapshot
The updated snapshot correctly reflects the addition of the global --no-color option with its description and default.

tests/snapshots/TestCLICommands_atmos_--help.stdout.golden (1)

60-60: Update global help snapshot to include --no-color
The addition of the --no-color flag to the global help output is correct and matches the new CLI behavior.

tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden (2)

80-81: Reflect unified no_color setting in configuration snapshot
The snapshot now includes "no_color": false under settings.terminal as expected.


150-150: Remove explicit editorconfig.color property
The editorconfig section is correctly simplified to {}, relying on the global no_color setting instead of a per-command color flag.

tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1)

73-73: Looks good - supports the new no-color global flag

The addition of --no-color as a global flag enhances accessibility for users with custom terminals where colored output might be hard to read.

tests/snapshots/TestCLICommands_atmos_describe_config_imports.stdout.golden (1)

123-123: Configuration schema correctly updated for no-color

The addition of no_color: false setting in the terminal configuration section ensures that the no-color option is properly represented in the config schema, while maintaining colored output as the default behavior.

pkg/schema/schema.go (1)

193-193: Schema update looks good

The NoColor field added to the Terminal struct properly supports the new feature with appropriate struct tags for YAML, JSON, and mapstructure.

cmd/root.go (2)

99-108: Well implemented color disabling for logs.

The implementation properly disables colors in logs when NoColor is set, while preserving other style attributes. This provides good accessibility for users with custom terminals who have difficulty reading colored output.


208-208: Good addition of global --no-color flag.

Adding this as a persistent flag at the root command level is the right approach, as it applies globally across all commands rather than requiring command-specific implementations.

website/docs/cli/configuration/terminal.mdx (2)

30-32: Properly updated terminal settings documentation.

The configuration example has been correctly updated to use no_color: false instead of the previous colors setting, maintaining consistency with the implementation.


81-83: Clear documentation for the new no_color option.

The added documentation for the no_color setting is clear and concise, making it easy for users to understand how to disable colored output.

pkg/config/load.go (2)

101-101: Good environment variable binding for no_color setting.

Binding both ATMOS_NO_COLOR and standard NO_COLOR environment variables follows best practices and provides users with flexibility. This correctly uses viper.BindEnv rather than direct os.Getenv calls as recommended.


118-118: Appropriate default for no_color setting.

Setting the default to false ensures colors remain enabled by default, which is the expected behavior.

tests/snapshots/TestCLICommands_atmos_support.stdout.golden (1)

1-19: New snapshot file looks good.

This new snapshot captures the expected plain-text output for the atmos support command, which aligns with the PR objective of adding no-color support for terminals that have difficulty with colored output.

pkg/config/config_test.go (1)

407-439: Good test coverage for flag parsing.

The test cases comprehensively cover parsing different flag configurations, which is important for validating the new --no-color flag functionality.

pkg/ui/markdown/renderer_test.go (1)

1-101: Well-structured tests for color rendering.

These tests comprehensively verify that the markdown renderer properly handles the no-color setting. Good practices observed:

  1. Testing both color and no-color scenarios
  2. Mocking TTY support functions for consistent testing
  3. Properly restoring original functions after tests
  4. Testing multiple rendering methods including error rendering

This ensures the no-color support works correctly throughout the rendering system.

Comment on lines 121 to 124
terminal:
no_color: false # Disable color output (Can also be set using 'ATMOS_NO_COLOR' or 'NO_COLOR' ENV var or '--no-color' command-line argument)
max_width: 120 # Maximum width for terminal output
pager: true # Use pager for long output
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Document the no_color setting under settings.terminal
The default example includes no_color, but the descriptive section for settings.terminal below does not list it. Please add a documentation entry explaining the no_color option.

Proposed diff:

  <dt>`pager`</dt>
  <dd>Use pager for long output</dd>
+ <dt>`no_color`</dt>
+ <dd>Disable color output. Can also be set via `ATMOS_NO_COLOR` or `NO_COLOR` env var or `--no-color` flag.</dd>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
terminal:
no_color: false # Disable color output (Can also be set using 'ATMOS_NO_COLOR' or 'NO_COLOR' ENV var or '--no-color' command-line argument)
max_width: 120 # Maximum width for terminal output
pager: true # Use pager for long output
<dt>`pager`</dt>
<dd>Use pager for long output</dd>
<dt>`no_color`</dt>
<dd>Disable color output. Can also be set via `ATMOS_NO_COLOR` or `NO_COLOR` env var or `--no-color` flag.</dd>
🤖 Prompt for AI Agents (early access)
In website/docs/cli/configuration/configuration.mdx around lines 121 to 124, the no_color setting under settings.terminal is missing documentation. Add a descriptive entry for no_color explaining that it disables color output in the terminal and can also be set using the ATMOS_NO_COLOR or NO_COLOR environment variables or the --no-color command-line argument.

Comment on lines +80 to +84
if flagKeyValue, ok := flagKeyValue["no-color"]; ok || flagKeyValue == "true" {
atmosConfig.Settings.Terminal.NoColor = true
} else if flagKeyValue == "false" {
atmosConfig.Settings.Terminal.NoColor = false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implementation handles flag parsing correctly

The code correctly processes the --no-color flag, setting the terminal configuration accordingly. The implementation properly handles both presence of the flag and explicit true/false values.

However, I noticed that the code coverage tools reported these lines aren't covered by tests. Consider adding test cases for these new lines to ensure robustness:

#!/bin/bash
# Check if there are tests for the no-color flag parsing
rg -A 3 "no.?color.*test" pkg/config/
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 83-84: pkg/config/config.go#L83-L84
Added lines #L83 - L84 were not covered by tests

🤖 Prompt for AI Agents (early access)
In pkg/config/config.go around lines 80 to 84, the code correctly handles the --no-color flag but lacks test coverage. Add unit tests that explicitly cover scenarios where the flag is present with no value, set to "true", and set to "false" to ensure these branches are exercised and the terminal configuration is set as expected.

Comment on lines +119 to 122
cliConfig.NoColor = atmosConfig.Settings.Terminal.NoColor
if atmosConfig.Settings.Terminal.NoColor {
cliConfig.NoColor = atmosConfig.Settings.Terminal.NoColor
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Redundant assignment in the conditional block.

Line 119 already assigns the same value, making the conditional check and reassignment in lines 120-121 unnecessary.

 cliConfig.NoColor = atmosConfig.Settings.Terminal.NoColor
-if atmosConfig.Settings.Terminal.NoColor {
-    cliConfig.NoColor = atmosConfig.Settings.Terminal.NoColor
-}
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 121-121: cmd/validate_editorconfig.go#L121
Added line #L121 was not covered by tests

🤖 Prompt for AI Agents (early access)
In cmd/validate_editorconfig.go around lines 119 to 122, there is a redundant assignment where cliConfig.NoColor is set twice to the same value from atmosConfig.Settings.Terminal.NoColor. Remove the if statement and the reassignment inside it, keeping only the initial assignment on line 119 to eliminate unnecessary code duplication.

Comment on lines +42 to +56
if atmosConfig.Settings.Terminal.NoColor {
renderer, err := glamour.NewTermRenderer(
glamour.WithStandardStyle(styles.AsciiStyle),
glamour.WithWordWrap(int(r.width)),
glamour.WithColorProfile(r.profile),
glamour.WithEmoji(),
)
if err != nil {
return nil, err
}

r.renderer = renderer
return r, nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Branches for color vs no-color duplicate large option blocks

Both here and in RenderWithoutWordWrap you duplicate 7 identical glamour.With… options, differing only in the style passed (styles.AsciiStyle vs auto/custom). Extracting a tiny helper like:

func newTermRenderer(style glamour.TermStyle, wrap int, prof termenv.Profile) (*glamour.TermRenderer, error) {
    return glamour.NewTermRenderer(
        glamour.WithStandardStyle(style),
        glamour.WithWordWrap(wrap),
        glamour.WithColorProfile(prof),
        glamour.WithEmoji(),
    )
}

will remove the duplication and slice the cognitive complexity flagged by the linter.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 50-51: pkg/ui/markdown/renderer.go#L50-L51
Added lines #L50 - L51 were not covered by tests

🤖 Prompt for AI Agents (early access)
In pkg/ui/markdown/renderer.go around lines 42 to 56, the code duplicates the same set of glamour.With... options for creating a TermRenderer in both color and no-color branches, differing only by the style used. To fix this, extract a helper function that accepts the style, wrap width, and color profile as parameters and returns a new TermRenderer with the common options applied. Replace the duplicated code blocks by calls to this helper, passing the appropriate style for each case, thereby reducing duplication and cognitive complexity.

Copy link

mergify bot commented May 7, 2025

💥 This pull request now has conflicts. Could you fix it @samtholiya? 🙏

@mergify mergify bot added the conflict This PR has conflicts label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor New features that do not break anything size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants