-
-
Notifications
You must be signed in to change notification settings - Fork 133
fix: disable pager mouse interactions and add global --pager flag #1430
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
base: main
Are you sure you want to change the base?
Conversation
- Remove tea.WithMouseCellMotion() to enable mouse text selection in pager - Change pager default from enabled to disabled for better scripting/automation - Add global --pager flag supporting true/false/command values - Add color field to terminal settings (deprecates no_color in config) - Support ATMOS_COLOR and COLOR environment variables - Update documentation with new global-flags.mdx page - Add comprehensive tests for pager and color functionality BREAKING CHANGE: Pager is now disabled by default. Use --pager flag or set pager: true in atmos.yaml to enable. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughCentralizes pager handling into global CLI config and environment parsing, defaults pager to disabled, introduces explicit Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant CLI as Atmos CLI
participant Root as RootCmd
participant Cfg as cfg.InitCliConfig
participant Env as Env Vars
participant File as atmos.yaml
participant Pager as pager.NewWithAtmosConfig
User->>CLI: atmos [--pager[=val]] <cmd> [flags]
CLI->>Root: start (register global flags)
Root->>Cfg: InitCliConfig()
Cfg->>Env: read ATMOS_PAGER/PAGER, ATMOS_COLOR/COLOR, NO_COLOR/ATMOS_NO_COLOR
Cfg->>File: load settings.terminal.{pager,color}
Cfg-->>Root: resolved config (flags > env > file > defaults)
alt help requested
Root->>Pager: NewWithAtmosConfig(pagerEnabled)
Pager-->>User: render help (paged or direct)
else command execution
Root->>Cfg: supply resolved settings to command runtime
CLI-->>User: command output (pager controlled globally)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
pkg/config/load.go (1)
138-141
: Defaults conflict with PR: pager should default to false; also set explicit default for color=true.Currently v.SetDefault("settings.terminal.pager", true) contradicts the new default (disabled). Also, without an explicit default for settings.terminal.color, a zero-value bool may unintentionally disable color depending on IsColorEnabled logic.
Apply:
v.SetDefault("settings.terminal.no_color", false) -v.SetDefault("settings.terminal.pager", true) +// Pager is disabled by default (can be enabled via config/env/flag). +v.SetDefault("settings.terminal.pager", false) +// Make color explicitly default-on; NO_COLOR still overrides via IsColorEnabled(). +v.SetDefault("settings.terminal.color", true) v.SetDefault("docs.generate.readme.output", "./README.md")Please add/adjust tests to assert:
- Default pager is false when no config/env/flags are provided.
- NO_COLOR overrides COLOR/ATMOS_COLOR and settings.terminal.color.
cmd/root.go (2)
101-111
: Honor new color semantics (use IsColorEnabled).This keeps behavior consistent when users set
color: false
(even ifno_color
is not set).- if atmosConfig.Settings.Terminal.NoColor { + if !atmosConfig.Settings.Terminal.IsColorEnabled() { stylesDefault := log.DefaultStyles() // Clear colors for levels styles := &log.Styles{} styles.Levels = make(map[log.Level]lipgloss.Style) for k := range stylesDefault.Levels { styles.Levels[k] = stylesDefault.Levels[k].UnsetForeground().Bold(false) } log.SetStyles(styles) }
289-293
: Shadowing imported package namepager
.Short var
pager := pager.New...
shadows the imported package and will failimportshadow
linters.- pager := pager.NewWithAtmosConfig(pagerEnabled) - if err := pager.Run("Atmos CLI Help", buf.String()); err != nil { + pg := pager.NewWithAtmosConfig(pagerEnabled) + if err := pg.Run("Atmos CLI Help", buf.String()); err != nil { log.Error("Failed to run pager", "error", err) utils.OsExit(1) }
♻️ Duplicate comments (1)
cmd/root.go (1)
273-287
: Normalize and switch on --pager value; simplifies and fixes case/whitespace.Also addresses the linter’s if-else chain warning.
- // Check if pager should be enabled based on flag, env var, or config - pagerEnabled := atmosConfig.Settings.Terminal.IsPagerEnabled() - - // Check if --pager flag was explicitly set - if pagerFlag, err := command.Flags().GetString("pager"); err == nil && pagerFlag != "" { - // Handle --pager flag values - if pagerFlag == "true" || pagerFlag == "on" || pagerFlag == "yes" || pagerFlag == "1" { - pagerEnabled = true - } else if pagerFlag == "false" || pagerFlag == "off" || pagerFlag == "no" || pagerFlag == "0" { - pagerEnabled = false - } else { - // Assume it's a pager command like "less" or "more" - pagerEnabled = true - } - } + // Start with config/env; override with --pager if explicitly set + pagerEnabled := atmosConfig.Settings.Terminal.IsPagerEnabled() + if pagerFlagRaw, err := command.Flags().GetString("pager"); err == nil && pagerFlagRaw != "" { + pf := strings.ToLower(strings.TrimSpace(pagerFlagRaw)) + switch pf { + case "true", "on", "yes", "1": + pagerEnabled = true + case "false", "off", "no", "0": + pagerEnabled = false + default: + // Treat any non-boolean value as a pager command (e.g. "less", "more", "less -SR") + pagerEnabled = true + } + }
🧹 Nitpick comments (14)
website/docs/cli/global-flags.mdx (2)
312-317
: Clarify PAGER=cat semantics.“Disables paging” is misleading; using cat bypasses interactive paging by writing directly to stdout.
Apply:
-export PAGER=cat # Disables paging in Atmos and other tools that respect PAGER +export PAGER=cat # Bypasses interactive paging (outputs directly to stdout)
356-361
: Missing punctuation.End the last bullet with a period for consistency.
-- **Better defaults**: Most modern terminals have built-in scrollback +- **Better defaults**: Most modern terminals have built-in scrollback.pkg/config/load.go (1)
231-249
: Optional: unify env access via Viper.readEnvAmosConfigPath uses os.Getenv; consider viper.AutomaticEnv + v.GetString for consistency with the rest of the config pipeline.
-func readEnvAmosConfigPath(v *viper.Viper) error { - atmosPath := os.Getenv("ATMOS_CLI_CONFIG_PATH") +func readEnvAmosConfigPath(v *viper.Viper) error { + _ = v.BindEnv("ATMOS_CLI_CONFIG_PATH") + atmosPath := v.GetString("ATMOS_CLI_CONFIG_PATH")pkg/pager/pager.go (2)
55-57
: Wrap Bubble Tea error with context.
Add context to aid debugging without losing the original error.- ).Run(); err != nil { - return err + ).Run(); err != nil { + return fmt.Errorf("pager: bubbletea program.Run failed: %w", err) }
11-14
: Add GoDoc for exported API.
Exported type and constructors lack comments; add concise docs for godoc and linters.//go:generate mockgen -source=$GOFILE -destination=mock_$GOFILE -package=$GOPACKAGE type PageCreator interface { Run(title, content string) error } type pageCreator struct {+// NewWithAtmosConfig returns a PageCreator honoring the provided pager enablement. func NewWithAtmosConfig(enablePager bool) PageCreator {
-func New() PageCreator { +// New returns a PageCreator with paging disabled by default. +func New() PageCreator {Also applies to: 23-36
pkg/schema/schema_test.go (1)
70-86
: Broaden pager tests for negative uppercase cases.
Add OFF/FALSE uppercase to mirror ON/TRUE coverage.{ - {"Capitalized 'ON' should enable pager", "ON", true}, - {"Capitalized 'TRUE' should enable pager", "TRUE", true}, + {"Capitalized 'ON' should enable pager", "ON", true}, + {"Capitalized 'TRUE' should enable pager", "TRUE", true}, + {"Capitalized 'OFF' should disable pager", "OFF", false}, + {"Capitalized 'FALSE' should disable pager", "FALSE", false}, }website/docs/cli/configuration/configuration.mdx (2)
122-127
: Document precedence explicitly in the defaults snippet.Suggest adding a one-line note so users see precedence at a glance.
max_width: 120 # Maximum width for terminal output pager: false # Pager disabled by default (set to true or pager command to enable) + # Precedence: flags > environment variables > config file > defaults
276-287
: Clarify color env vars and precedence; note NO_COLOR wins.Make precedence and variables unambiguous to prevent surprises.
- <dd>Enable or disable colored output (default: `true`). Can be overridden with `--no-color` flag or `NO_COLOR`/`ATMOS_NO_COLOR` environment variables.</dd> + <dd>Enable or disable colored output (default: `true`). Precedence: flags > env > config. Supports `ATMOS_COLOR`/`COLOR` to force enable/disable; `NO_COLOR`/`ATMOS_NO_COLOR` always disable and take precedence over `COLOR`.</dd> @@ - **Environment Variables Still Supported**: The `NO_COLOR` and `ATMOS_NO_COLOR` environment variables remain fully supported for portability across different environments and CI/CD systems. + **Environment Variables Still Supported**: `NO_COLOR` and `ATMOS_NO_COLOR` remain fully supported and take precedence over `COLOR`/`ATMOS_COLOR`. `ATMOS_COLOR` and `COLOR` can be used to enable or disable color when `NO_COLOR` is not set.pkg/schema/schema.go (1)
223-231
: Fix comment to match behavior.The function cannot infer an "unset" bool; defaults come from config layer.
- // Use Color setting (defaults to true if not explicitly set) + // Use Color setting; deprecated NoColor overridespkg/pager/pager_test.go (2)
97-100
: Avoid brittle count assertion on ProgramOptions.Assert presence (>=1) rather than an exact count.
- assert.Len(t, capturedOpts, 1, "Should have 1 tea program option (WithAltScreen)") + assert.GreaterOrEqual(t, len(capturedOpts), 1, "Should include WithAltScreen option")
228-230
: Mirror the non-brittle option check here too.- assert.Len(t, capturedOpts, 1, "Should have 1 tea program option (WithAltScreen)") + assert.GreaterOrEqual(t, len(capturedOpts), 1, "Should include WithAltScreen option")cmd/root.go (1)
212-215
: Tighten flag help text: default and precedence.Clarify behavior and examples.
- RootCmd.PersistentFlags().String("pager", "", "Enable pager for output (--pager or --pager=true to enable, --pager=false to disable, --pager=less to use specific pager)") + RootCmd.PersistentFlags().String("pager", "", "Control paging of help/long output (default: disabled). Use --pager or --pager=true to enable, --pager=false to disable, or --pager='less -SR' to use a specific pager. Flag overrides config/env.")pkg/config/config_test.go (2)
532-611
: Expand parseFlags coverage for --pager synonyms and bare flagsDocs mention accepting true/false/command; they also say “on”. Add cases to ensure we parse "--pager=on" and the bare "--pager" form consistently.
Apply:
@@ func TestParseFlagsForPager(t *testing.T) { { name: "pager flag with true", args: []string{"atmos", "describe", "config", "--pager=true"}, expectedPager: "true", expectedNoColor: false, }, + { + name: "pager flag with on", + args: []string{"atmos", "describe", "config", "--pager=on"}, + expectedPager: "on", + expectedNoColor: false, + }, + { + name: "bare pager flag enables pager", + args: []string{"atmos", "describe", "config", "--pager"}, + expectedPager: "true", + expectedNoColor: false, + },
613-667
: Cover boolean variants in setLogConfig (pager true/false)Add tests to ensure CLI-only toggles work without env influence.
Apply:
@@ func TestSetLogConfigWithPager(t *testing.T) { tests := []struct { name string args []string expectedPager string expectedNoColor bool expectedColor bool }{ { name: "pager from flag", args: []string{"atmos", "--pager=less"}, expectedPager: "less", expectedNoColor: false, }, + { + name: "pager true via bare flag", + args: []string{"atmos", "--pager"}, + expectedPager: "true", + expectedNoColor: false, + }, + { + name: "pager false via flag", + args: []string{"atmos", "--pager=false"}, + expectedPager: "false", + expectedNoColor: false, + }, { name: "no-color flag sets both NoColor and Color", args: []string{"atmos", "--no-color"}, expectedPager: "", expectedNoColor: true, expectedColor: false, },
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (18)
atmos.yaml
(1 hunks)cmd/describe.go
(0 hunks)cmd/describe_affected.go
(1 hunks)cmd/describe_config.go
(1 hunks)cmd/describe_dependents.go
(1 hunks)cmd/describe_stacks.go
(1 hunks)cmd/describe_workflows.go
(1 hunks)cmd/root.go
(2 hunks)pkg/config/config.go
(1 hunks)pkg/config/config_test.go
(1 hunks)pkg/config/load.go
(1 hunks)pkg/pager/pager.go
(2 hunks)pkg/pager/pager_test.go
(4 hunks)pkg/schema/schema.go
(1 hunks)pkg/schema/schema_test.go
(2 hunks)website/docs/cli/configuration/configuration.mdx
(3 hunks)website/docs/cli/configuration/terminal.mdx
(3 hunks)website/docs/cli/global-flags.mdx
(1 hunks)
💤 Files with no reviewable changes (1)
- cmd/describe.go
🧰 Additional context used
📓 Path-based instructions (4)
cmd/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
cmd/*.go
: Implement each Cobra command in a separate file under the cmd/ directory
Use kebab-case for command-line flags
Provide comprehensive help text for all commands and flags
Include examples in command help
Provide meaningful feedback to users in command implementation
Include progress indicators for long-running operations
Provide clear error messages to users
Include troubleshooting hints when appropriate
Log detailed errors for debugging
Files:
cmd/describe_workflows.go
cmd/describe_dependents.go
cmd/describe_affected.go
cmd/describe_stacks.go
cmd/root.go
cmd/describe_config.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go
: Use Viper for managing configuration, environment variables, and flags
Use interfaces for external dependencies to facilitate mocking
All code must pass golangci-lint checks
Follow Go's error handling idioms
Use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider using a custom error type for domain-specific errors
Follow standard Go coding style
Use gofmt and goimports to format code
Prefer short, descriptive variable names
Use snake_case for environment variables
Document all exported functions, types, and methods
Document complex logic with inline comments
Follow Go's documentation conventions
Use Viper for configuration management
Support configuration via files, environment variables, and flags
Follow the precedence order: flags > environment variables > config file > defaults
Files:
cmd/describe_workflows.go
cmd/describe_dependents.go
pkg/config/load.go
cmd/describe_affected.go
pkg/config/config.go
pkg/pager/pager.go
pkg/schema/schema.go
cmd/describe_stacks.go
cmd/root.go
pkg/schema/schema_test.go
cmd/describe_config.go
pkg/config/config_test.go
pkg/pager/pager_test.go
website/**
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
website/**
: Update website documentation in the website/ directory when adding new features
Follow the website's documentation structure and style
Keep website code in the website/ directory
Follow the existing website architecture and style
Document new features on the website
Include examples and use cases in website documentation
Files:
website/docs/cli/global-flags.mdx
website/docs/cli/configuration/terminal.mdx
website/docs/cli/configuration/configuration.mdx
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go
: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for testing multiple scenarios
Include integration tests for command flows
Test CLI end-to-end when possible
Use test fixtures for complex inputs
Consider using testify/mock for creating mock implementations
Files:
pkg/schema/schema_test.go
pkg/config/config_test.go
pkg/pager/pager_test.go
🧠 Learnings (19)
📚 Learning: 2025-05-22T19:58:32.988Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected.go:122-123
Timestamp: 2025-05-22T19:58:32.988Z
Learning: The "pager" flag is defined as a PersistentFlag at the describe command level in cmd/describe.go, making it available to all subcommands including describeAffectedCmd without needing to redeclare it.
Applied to files:
cmd/describe_workflows.go
cmd/describe_dependents.go
cmd/describe_affected.go
pkg/config/config.go
cmd/describe_stacks.go
cmd/root.go
cmd/describe_config.go
📚 Learning: 2025-08-16T23:32:40.412Z
Learnt from: aknysh
PR: cloudposse/atmos#1405
File: internal/exec/describe_dependents_test.go:455-456
Timestamp: 2025-08-16T23:32:40.412Z
Learning: In the cloudposse/atmos Go codebase, `InitCliConfig` returns a `schema.AtmosConfiguration` value (not a pointer), while `ExecuteDescribeDependents` expects a `*schema.AtmosConfiguration` pointer parameter. Therefore, when passing the result of `InitCliConfig` to `ExecuteDescribeDependents`, use `&atmosConfig` to pass the address of the value.
Applied to files:
cmd/describe_workflows.go
cmd/describe_dependents.go
cmd/describe_stacks.go
cmd/describe_config.go
📚 Learning: 2025-08-16T23:33:07.477Z
Learnt from: aknysh
PR: cloudposse/atmos#1405
File: internal/exec/describe_dependents_test.go:651-652
Timestamp: 2025-08-16T23:33:07.477Z
Learning: In the cloudposse/atmos Go codebase, ExecuteDescribeDependents expects a pointer to AtmosConfiguration (*schema.AtmosConfiguration), so when calling it with a value returned by cfg.InitCliConfig (which returns schema.AtmosConfiguration), the address-of operator (&) is necessary: ExecuteDescribeDependents(&atmosConfig, ...).
Applied to files:
cmd/describe_dependents.go
cmd/describe_stacks.go
cmd/describe_config.go
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Applied to files:
cmd/describe_dependents.go
cmd/describe_config.go
📚 Learning: 2024-10-31T19:25:41.298Z
Learnt from: osterman
PR: cloudposse/atmos#727
File: internal/exec/terraform_clean.go:233-235
Timestamp: 2024-10-31T19:25:41.298Z
Learning: When specifying color values in functions like `confirmDeleteTerraformLocal` in `internal/exec/terraform_clean.go`, avoid hardcoding color values. Instead, use predefined color constants or allow customization through configuration settings to improve accessibility and user experience across different terminals and themes.
Applied to files:
pkg/config/load.go
pkg/config/config.go
pkg/schema/schema.go
📚 Learning: 2025-04-10T20:48:22.687Z
Learnt from: samtholiya
PR: cloudposse/atmos#1147
File: pkg/config/load.go:0-0
Timestamp: 2025-04-10T20:48:22.687Z
Learning: In the `bindEnv` function in `pkg/config/load.go`, panic is used deliberately instead of returning errors because errors from `BindEnv` would only occur due to developer mistakes. Using panic helps with early detection of these developer errors during initialization.
Applied to files:
pkg/config/load.go
📚 Learning: 2025-04-23T15:02:50.246Z
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.
Applied to files:
pkg/config/load.go
📚 Learning: 2025-08-15T14:43:41.030Z
Learnt from: aknysh
PR: cloudposse/atmos#1352
File: pkg/store/artifactory_store_test.go:108-113
Timestamp: 2025-08-15T14:43:41.030Z
Learning: In test files for the atmos project, it's acceptable to ignore errors from os.Setenv/Unsetenv operations during test environment setup and teardown, as these are controlled test scenarios.
Applied to files:
pkg/config/load.go
pkg/config/config_test.go
📚 Learning: 2025-06-23T02:14:30.937Z
Learnt from: aknysh
PR: cloudposse/atmos#1327
File: cmd/terraform.go:111-117
Timestamp: 2025-06-23T02:14:30.937Z
Learning: In cmd/terraform.go, flags for the DescribeAffected function are added dynamically at runtime when info.Affected is true. This is intentional to avoid exposing internal flags like "file", "format", "verbose", "include-spacelift-admin-stacks", "include-settings", and "upload" in the terraform command interface, while still providing them for the shared DescribeAffected function used by both `atmos describe affected` and `atmos terraform apply --affected`.
Applied to files:
cmd/describe_affected.go
cmd/describe_stacks.go
📚 Learning: 2024-12-12T17:13:53.409Z
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Applied to files:
cmd/describe_affected.go
pkg/pager/pager.go
cmd/root.go
cmd/describe_config.go
📚 Learning: 2024-11-13T21:37:07.852Z
Learnt from: Cerebrovinny
PR: cloudposse/atmos#764
File: internal/exec/describe_stacks.go:289-295
Timestamp: 2024-11-13T21:37:07.852Z
Learning: In the `internal/exec/describe_stacks.go` file of the `atmos` project written in Go, avoid extracting the stack name handling logic into a helper function within the `ExecuteDescribeStacks` method, even if the logic appears duplicated.
Applied to files:
cmd/describe_stacks.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to cmd/*.go : Provide comprehensive help text for all commands and flags
Applied to files:
cmd/root.go
📚 Learning: 2024-12-11T18:46:02.483Z
Learnt from: Listener430
PR: cloudposse/atmos#844
File: cmd/terraform.go:39-39
Timestamp: 2024-12-11T18:46:02.483Z
Learning: `cliConfig` is initialized in `cmd/root.go` and can be used across the `cmd` package.
Applied to files:
cmd/root.go
📚 Learning: 2025-01-30T19:30:59.120Z
Learnt from: samtholiya
PR: cloudposse/atmos#959
File: cmd/workflow.go:74-74
Timestamp: 2025-01-30T19:30:59.120Z
Learning: Error handling for `cmd.Usage()` is not required in the Atmos CLI codebase, as confirmed by the maintainer.
Applied to files:
cmd/root.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Test both happy paths and error conditions
Applied to files:
pkg/schema/schema_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Use table-driven tests for testing multiple scenarios
Applied to files:
pkg/schema/schema_test.go
pkg/pager/pager_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*.go : Follow the precedence order: flags > environment variables > config file > defaults
Applied to files:
pkg/config/config_test.go
📚 Learning: 2025-02-20T13:57:36.326Z
Learnt from: osterman
PR: cloudposse/atmos#1036
File: cmd/list_settings.go:46-50
Timestamp: 2025-02-20T13:57:36.326Z
Learning: The max-columns flag in Atmos list commands supports -1 for unlimited width, which bypasses terminal width restrictions and may require horizontal scrolling. The default is 10 columns if not specified.
Applied to files:
website/docs/cli/configuration/terminal.mdx
📚 Learning: 2025-01-09T19:53:29.847Z
Learnt from: Listener430
PR: cloudposse/atmos#912
File: pkg/config/config.go:91-92
Timestamp: 2025-01-09T19:53:29.847Z
Learning: In the Atmos project, the `core.inject_github_token` configuration is required to be enabled (`true`) by default to support authenticated GitHub requests and help bypass rate limits.
Applied to files:
website/docs/cli/configuration/configuration.mdx
🧬 Code graph analysis (5)
pkg/config/config.go (1)
pkg/schema/schema.go (2)
Settings
(851-855)Terminal
(203-211)
cmd/root.go (2)
pkg/schema/schema.go (2)
Settings
(851-855)Terminal
(203-211)pkg/pager/pager.go (1)
NewWithAtmosConfig
(23-27)
pkg/schema/schema_test.go (1)
pkg/schema/schema.go (1)
Terminal
(203-211)
pkg/config/config_test.go (1)
pkg/schema/schema.go (4)
AtmosConfiguration
(25-60)Settings
(851-855)AtmosSettings
(243-263)Terminal
(203-211)
pkg/pager/pager_test.go (1)
pkg/pager/pager.go (1)
NewWithAtmosConfig
(23-27)
🪛 LanguageTool
website/docs/cli/global-flags.mdx
[grammar] ~7-~7: There might be a mistake here.
Context: ...Intro from '@site/src/components/Intro'; import Note from '@site/src/components/N...
(QB_NEW_EN)
[grammar] ~183-~183: There might be a mistake here.
Context: ...1. Command-line flags (highest priority) 2. Environment variables 3. Configuration f...
(QB_NEW_EN)
[grammar] ~184-~184: There might be a mistake here.
Context: ...ghest priority) 2. Environment variables 3. Configuration file (atmos.yaml
) 4. Def...
(QB_NEW_EN)
[grammar] ~185-~185: There might be a mistake here.
Context: ...les 3. Configuration file (atmos.yaml
) 4. Default values (lowest priority) ### Co...
(QB_NEW_EN)
[grammar] ~360-~360: Please add a punctuation mark at the end of paragraph.
Context: ...**: Most modern terminals have built-in scrollback ## See Also - [CLI Configuration](/cl...
(PUNCTUATION_PARAGRAPH_END)
🪛 GitHub Check: golangci-lint
cmd/root.go
[failure] 279-279:
ifElseChain: rewrite if-else to switch statement
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Summary
🔇 Additional comments (17)
atmos.yaml (1)
352-357
: Pager default switched off — good.This aligns atmos.yaml with the PR’s breaking change and docs.
cmd/describe_affected.go (1)
73-76
: Global --pager is already applied in ParseDescribeAffectedCliArgs
ParseDescribeAffectedCliArgs invokes cfg.InitCliConfig(info, true), which processes the global --pager flag into atmosConfig.Settings.Terminal.Pager, and then SetDescribeAffectedFlagValueInCliArgs maps “pager” onto props.CLIConfig.Settings.Terminal.Pager. No changes needed here.website/docs/cli/global-flags.mdx (1)
322-329
: Ensure auto-disable implemented in CLI code
Doc states that paging and color are disabled when output is piped, but no TTY-detection (e.g.isatty
/terminal.IsTerminal
) was found in the code. Confirm the CLI checks stdout for a real TTY and disables pager/color on pipes, or update the docs to match actual behavior.cmd/describe_workflows.go (1)
55-57
: LGTM: pager handling centralized.This command path initializes via cfg.InitCliConfig and passes atmosConfig through; removing local pager handling is correct.
pkg/pager/pager.go (2)
31-31
: Default pager now disabled — verify precedence and UX copy.
Confirm flags > env vars > config > defaults behavior is preserved end-to-end and docs/examples reflect the new default.
54-55
: Mouse motion tracking removed: selection fix looks good.
Dropping tea.WithMouseCellMotion avoids capturing drag events. Nice.cmd/describe_dependents.go (1)
57-57
: Pager handling centralized: LGTM.
Removing per-command overrides reduces duplication and honors global init.cmd/describe_stacks.go (1)
73-73
: Pager handling centralized: LGTM.
Consistent with other describe commands and root-level flag.pkg/schema/schema_test.go (1)
40-62
: Color precedence tests read well.
Covers all key combinations; clear expectation that NoColor wins.pkg/config/config.go (1)
87-90
: Global --pager propagation: OK.
Simple assignment keeps precedence consistent with other flags.pkg/schema/schema.go (1)
208-211
: Public color fields: OK, but ensure deprecation path is surfaced in docs/tests.Fields and tags look fine; rely on IsColorEnabled() where possible.
Please ensure tests cover both Color=false and NoColor=true interactions (including env overrides).
pkg/pager/pager_test.go (2)
173-190
: Constructor coverage: LGTM.Good coverage of enabled/disabled toggles.
240-246
: Explicit “pager disabled” case: nice.Covers the new default well.
website/docs/cli/configuration/terminal.mdx (4)
30-33
: Defaults align with PR (pager off, color on)Matches stated behavior. Good.
37-45
: Clear deprecation messagingGood split between config deprecation and env portability.
115-115
: Syntax-highlighting pager independence is clearGood clarification.
61-91
: Reflect ‘on’ support & document precedence
- Update pager docs in website/docs/cli/configuration/terminal.mdx to
“- true or on: Enable pager with system default
” (tests confirmon
is accepted).- Append a tip under the
<dl>
outlining Atmos’s setting resolution order:
- CLI flags
- Environment variables
- Config file
- Defaults
Verify code respects this precedence.
func TestEnvironmentVariableHandling(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
envVars map[string]string | ||
args []string | ||
expectedPager string | ||
expectedNoColor bool | ||
expectedColor bool | ||
}{ | ||
{ | ||
name: "ATMOS_PAGER environment variable", | ||
envVars: map[string]string{ | ||
"ATMOS_PAGER": "more", | ||
}, | ||
args: []string{"atmos", "describe", "config"}, | ||
expectedPager: "more", | ||
}, | ||
{ | ||
name: "NO_COLOR environment variable", | ||
envVars: map[string]string{ | ||
"NO_COLOR": "1", | ||
}, | ||
args: []string{"atmos", "describe", "config"}, | ||
expectedNoColor: true, | ||
expectedColor: false, | ||
}, | ||
{ | ||
name: "ATMOS_NO_COLOR environment variable", | ||
envVars: map[string]string{ | ||
"ATMOS_NO_COLOR": "true", | ||
}, | ||
args: []string{"atmos", "describe", "config"}, | ||
expectedNoColor: true, | ||
expectedColor: false, | ||
}, | ||
{ | ||
name: "COLOR environment variable", | ||
envVars: map[string]string{ | ||
"COLOR": "true", | ||
}, | ||
args: []string{"atmos", "describe", "config"}, | ||
expectedColor: true, | ||
}, | ||
{ | ||
name: "ATMOS_COLOR environment variable", | ||
envVars: map[string]string{ | ||
"ATMOS_COLOR": "true", | ||
}, | ||
args: []string{"atmos", "describe", "config"}, | ||
expectedColor: true, | ||
}, | ||
{ | ||
name: "CLI flag overrides environment variable", | ||
envVars: map[string]string{ | ||
"ATMOS_PAGER": "more", | ||
}, | ||
args: []string{"atmos", "--pager=less", "describe", "config"}, | ||
expectedPager: "less", | ||
}, | ||
{ | ||
name: "Multiple environment variables with precedence", | ||
envVars: map[string]string{ | ||
"COLOR": "true", | ||
"NO_COLOR": "1", | ||
"ATMOS_PAGER": "cat", | ||
}, | ||
args: []string{"atmos", "describe", "config"}, | ||
expectedPager: "cat", | ||
expectedNoColor: true, | ||
expectedColor: false, // NO_COLOR takes precedence | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
// Save original state | ||
originalArgs := os.Args | ||
originalEnvVars := make(map[string]string) | ||
|
||
// Clear and save relevant environment variables | ||
envVarsToCheck := []string{"ATMOS_PAGER", "NO_COLOR", "ATMOS_NO_COLOR", "COLOR", "ATMOS_COLOR"} | ||
for _, envVar := range envVarsToCheck { | ||
if val, exists := os.LookupEnv(envVar); exists { | ||
originalEnvVars[envVar] = val | ||
} | ||
os.Unsetenv(envVar) | ||
} | ||
|
||
defer func() { | ||
// Restore original state | ||
os.Args = originalArgs | ||
// Restore environment variables | ||
for _, envVar := range envVarsToCheck { | ||
os.Unsetenv(envVar) | ||
} | ||
for envVar, val := range originalEnvVars { | ||
os.Setenv(envVar, val) | ||
} | ||
}() | ||
|
||
// Set test environment variables | ||
for envVar, val := range tt.envVars { | ||
os.Setenv(envVar, val) | ||
} | ||
|
||
// Set test args | ||
if tt.args != nil { | ||
os.Args = tt.args | ||
} | ||
|
||
// Create a test viper instance and bind environment variables | ||
v := viper.New() | ||
v.SetEnvPrefix("ATMOS") | ||
v.AutomaticEnv() | ||
|
||
// Bind specific environment variables | ||
v.BindEnv("settings.terminal.pager", "ATMOS_PAGER") | ||
v.BindEnv("settings.terminal.no_color", "ATMOS_NO_COLOR", "NO_COLOR") | ||
v.BindEnv("settings.terminal.color", "ATMOS_COLOR", "COLOR") | ||
|
||
// Create a test config | ||
atmosConfig := &schema.AtmosConfiguration{ | ||
Settings: schema.AtmosSettings{ | ||
Terminal: schema.Terminal{}, | ||
}, | ||
} | ||
|
||
// Apply environment variables to config | ||
if envPager := v.GetString("settings.terminal.pager"); envPager != "" { | ||
atmosConfig.Settings.Terminal.Pager = envPager | ||
} | ||
if v.IsSet("settings.terminal.no_color") { | ||
atmosConfig.Settings.Terminal.NoColor = v.GetBool("settings.terminal.no_color") | ||
// When NoColor is set, Color should be false | ||
if atmosConfig.Settings.Terminal.NoColor { | ||
atmosConfig.Settings.Terminal.Color = false | ||
} | ||
} | ||
if v.IsSet("settings.terminal.color") && !atmosConfig.Settings.Terminal.NoColor { | ||
// Only set Color if NoColor is not true | ||
atmosConfig.Settings.Terminal.Color = v.GetBool("settings.terminal.color") | ||
} | ||
|
||
// Apply CLI flags (simulating what setLogConfig does) | ||
setLogConfig(atmosConfig) | ||
|
||
// Verify results | ||
if tt.expectedPager != "" { | ||
assert.Equal(t, tt.expectedPager, atmosConfig.Settings.Terminal.Pager, "Pager setting mismatch") | ||
} | ||
assert.Equal(t, tt.expectedNoColor, atmosConfig.Settings.Terminal.NoColor, "NoColor setting mismatch") | ||
if tt.expectedColor || tt.expectedNoColor { | ||
// Only check Color field if we expect it to be set | ||
expectedColorValue := tt.expectedColor && !tt.expectedNoColor | ||
assert.Equal(t, expectedColorValue, atmosConfig.Settings.Terminal.Color, "Color setting mismatch") | ||
} | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Avoid re-implementing env merge logic in tests; add PAGER and flag>env precedence cases
This test manually mirrors env handling, which can drift from production. Prefer exercising the real binding path or extracting a helper for env→config application and testing that. Also, docs say PAGER is supported; add coverage. Add precedence cases for NO_COLOR vs --no-color=false and ATMOS_COLOR with --no-color.
Apply:
@@ func TestEnvironmentVariableHandling(t *testing.T) {
- envVarsToCheck := []string{"ATMOS_PAGER", "NO_COLOR", "ATMOS_NO_COLOR", "COLOR", "ATMOS_COLOR"}
+ envVarsToCheck := []string{"ATMOS_PAGER", "PAGER", "NO_COLOR", "ATMOS_NO_COLOR", "COLOR", "ATMOS_COLOR"}
@@
- v.BindEnv("settings.terminal.pager", "ATMOS_PAGER")
+ v.BindEnv("settings.terminal.pager", "ATMOS_PAGER", "PAGER")
@@
tests := []struct {
name string
envVars map[string]string
args []string
expectedPager string
expectedNoColor bool
expectedColor bool
}{
@@
{
name: "ATMOS_PAGER environment variable",
envVars: map[string]string{
"ATMOS_PAGER": "more",
},
args: []string{"atmos", "describe", "config"},
expectedPager: "more",
},
+ {
+ name: "PAGER environment variable",
+ envVars: map[string]string{
+ "PAGER": "less",
+ },
+ args: []string{"atmos", "describe", "config"},
+ expectedPager: "less",
+ },
@@
{
name: "CLI flag overrides environment variable",
envVars: map[string]string{
"ATMOS_PAGER": "more",
},
args: []string{"atmos", "--pager=less", "describe", "config"},
expectedPager: "less",
},
+ {
+ name: "CLI flag overrides NO_COLOR env (re-enables color)",
+ envVars: map[string]string{
+ "NO_COLOR": "1",
+ },
+ args: []string{"atmos", "--no-color=false"},
+ expectedNoColor: false,
+ expectedColor: true,
+ },
+ {
+ name: "CLI --no-color overrides ATMOS_COLOR=true",
+ envVars: map[string]string{
+ "ATMOS_COLOR": "true",
+ },
+ args: []string{"atmos", "--no-color"},
+ expectedNoColor: true,
+ expectedColor: false,
+ },
+ {
+ name: "CLI --pager=false overrides env PAGER",
+ envVars: map[string]string{
+ "PAGER": "more",
+ },
+ args: []string{"atmos", "--pager=false"},
+ expectedPager: "false",
+ },
Optionally, replace manual env get/set with t.Setenv for brevity.
To confirm docs vs code, search for PAGER support and boolean parsing of “on”:
🏁 Script executed:
#!/bin/bash
# Verify env support and parsing behaviors
rg -n --type=go -C2 -e 'BindEnv\([^)]*pager' -e '\bPAGER\b' -e 'ATMOS_PAGER' -e 'NO_COLOR' -e 'ATMOS_COLOR' -e '--pager' -e '--no-color'
Length of output: 13489
Use a shared helper for env→config binding and update tests to cover PAGER and flag-precedence cases
- Refactor the Viper BindEnv/Get and config-assignment logic into a helper that both pkg/config/load.go and TestEnvironmentVariableHandling invoke, rather than duplicating it in the test.
- In TestEnvironmentVariableHandling, clear, bind, and test “PAGER” alongside “ATMOS_PAGER” and add cases for flag > env precedence (e.g.
--no-color=false
,--no-color
vsATMOS_COLOR
,--pager=false
vsPAGER
).
…uracy - Replace if-else chain with switch statement for better readability (cmd/root.go) - Fix documentation: move Stack/Component flags to Command-Specific section - Remove Breaking Change section from documentation (better suited for release notes) These changes address code quality concerns raised by GitHub's advanced security scanner and improve the accuracy of the documentation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
website/docs/cli/global-flags.mdx (2)
254-268
: Add arg-passing examples for pager.Show common real-world forms with quotes.
Apply:
# Enable pager (multiple ways) atmos describe config --pager # Enable with default pager atmos describe config --pager=true # Explicitly enable - atmos describe config --pager=less # Use specific pager + atmos describe config --pager=less # Use specific pager + atmos describe config --pager="less -RFX" # Pager with arguments ATMOS_PAGER=true atmos describe config # Via environment variable + PAGER="less -RFX" atmos describe config # Standard env var with arguments
312-315
: Reword: PAGER=cat doesn’t “disable” paging; it pass-throughs.Avoid implying special handling. It effectively bypasses paging.
Apply:
-export PAGER=cat # Disables paging in Atmos and other tools that respect PAGER +export PAGER=cat # Effectively bypasses paging by streaming output
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
cmd/root.go
(2 hunks)website/docs/cli/global-flags.mdx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- cmd/root.go
🧰 Additional context used
📓 Path-based instructions (1)
website/**
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
website/**
: Update website documentation in the website/ directory when adding new features
Follow the website's documentation structure and style
Keep website code in the website/ directory
Follow the existing website architecture and style
Document new features on the website
Include examples and use cases in website documentation
Files:
website/docs/cli/global-flags.mdx
🧠 Learnings (1)
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*.go : Follow the precedence order: flags > environment variables > config file > defaults
Applied to files:
website/docs/cli/global-flags.mdx
🪛 LanguageTool
website/docs/cli/global-flags.mdx
[grammar] ~7-~7: There might be a mistake here.
Context: ...Intro from '@site/src/components/Intro'; import Note from '@site/src/components/N...
(QB_NEW_EN)
[grammar] ~183-~183: There might be a mistake here.
Context: ...1. Command-line flags (highest priority) 2. Environment variables 3. Configuration f...
(QB_NEW_EN)
[grammar] ~184-~184: There might be a mistake here.
Context: ...ghest priority) 2. Environment variables 3. Configuration file (atmos.yaml
) 4. Def...
(QB_NEW_EN)
[grammar] ~185-~185: There might be a mistake here.
Context: ...les 3. Configuration file (atmos.yaml
) 4. Default values (lowest priority) ### Co...
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: website-deploy-preview
- GitHub Check: Summary
🔇 Additional comments (5)
website/docs/cli/global-flags.mdx (5)
181-187
: Precedence order is correctly documented.Matches the established rule: flags > env vars > config > defaults.
322-329
: Verify auto-disable behavior when piped; tighten wording.Confirm the implementation disables the pager when stdout is non-TTY, and be explicit about color behavior.
Apply:
-<Note> -When output is piped to another command, Atmos automatically disables color output and pager to ensure compatibility: +<Note> +When output is piped (stdout is not a TTY), Atmos automatically disables the pager. Color follows the usual precedence (flags/env/config); use `--no-color` or `NO_COLOR` to force-disable:To verify, please confirm stdout TTY checks are applied in the pager/color initialization paths.
200-215
: Color precedence and portability look good.Clear precedence of NO_COLOR over COLOR and dual support of ATMOS_* is well stated.
225-233
: Portability section is solid.Good explanation of dual env var support.
77-83
: Documentation confirmed for--redirect-stderr
: the flag is registered globally on RootCmd (cmd/root.go) with semantics matching the docs (supports any file path or standard file descriptor).
<dt>`--logs-level`</dt> | ||
<dd> | ||
Set the logging level for Atmos operations. | ||
- Options: `Trace`, `Debug`, `Info`, `Warning`, `Off` | ||
- Default: `Info` | ||
- Can also use `ATMOS_LOGS_LEVEL` environment variable | ||
</dd> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Confirm approved log levels and exact strings.
Validate the accepted values and default (e.g., Trace/Debug/Info/Warn/Error/Off vs “Warning”). Align docs with code.
Run:
🏁 Script executed:
#!/bin/bash
# Locate flag definition and accepted values
rg -nP -C3 '\blogs[-_.]level\b' --type=go
rg -nP -C2 '\b(Trace|Debug|Info|Warn|Warning|Error|Off)\b' --type=go
Length of output: 308757
Docs and flag text are correct — canonical levels: Trace, Debug, Info, Warning, Off (default: Info).
Matches cmd/root.go description and pkg/logger constants/tests.
- Action: fix casing inconsistency in internal/exec/validate_editorconfig.go:114-119 — it checks for "trace" (lowercase); use the canonical "Trace" or LogLevelTrace / logger.ParseLogLevel instead.
🤖 Prompt for AI Agents
In internal/exec/validate_editorconfig.go around lines 114 to 119, the code
checks for the lowercase string "trace" which is inconsistent with the canonical
log level casing used elsewhere (Trace). Replace the literal lowercase check by
using the canonical LogLevel constant (e.g., LogLevelTrace) or by parsing the
value via logger.ParseLogLevel and comparing against the parsed enum; update the
comparison so it accepts the canonical "Trace" casing and/or uses the logger
utilities to avoid direct string comparisons.
This commit addresses comprehensive feedback from PR review covering code quality, documentation accuracy, test coverage, and consistency. Changes implemented: • Fix case/whitespace handling in pager value parsing (schema.go) • Enhance --pager documentation with examples and quoting guidance • Fix --no-color flag parsing to properly handle true/false values • Remove redundant per-command pager logic in favor of global handling • Replace direct NoColor field access with IsColorEnabled() method • Fix log level comparison to use canonical constants instead of strings • Add comprehensive test coverage for PAGER env vars and flag precedence Technical improvements: - Pager values now normalized with strings.ToLower(strings.TrimSpace()) - Flag parsing avoids variable shadowing and properly validates values - Removed conflicting per-command pager overrides - Enhanced environment variable precedence testing - Documentation includes practical examples for shell quoting All existing tests pass with improved coverage and robustness. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/validate_editorconfig.go (1)
101-113
: Fix format flag shadowing and wrong error valueThe local
format := outputformat.OutputFormat(format)
shadows the package-levelformat
and the error path reports the config value instead of the flag value.Apply:
- format := outputformat.OutputFormat(atmosConfig.Validate.EditorConfig.Format) - if ok := format.IsValid(); !ok { + cfgFmt := outputformat.OutputFormat(atmosConfig.Validate.EditorConfig.Format) + if ok := cfgFmt.IsValid(); !ok { errUtils.CheckErrorPrintAndExit(fmt.Errorf("%v is not a valid format choose from the following: %v", atmosConfig.Validate.EditorConfig.Format, outputformat.GetArgumentChoiceText()), "", "") } - cliConfig.Format = format + cliConfig.Format = cfgFmt ... -} else if cmd.Flags().Changed("format") { - format := outputformat.OutputFormat(format) - if ok := format.IsValid(); !ok { - errUtils.CheckErrorPrintAndExit(fmt.Errorf("%v is not a valid format choose from the following: %v", atmosConfig.Validate.EditorConfig.Format, outputformat.GetArgumentChoiceText()), "", "") - } - cliConfig.Format = format +} else if cmd.Flags().Changed("format") { + flagFmt := outputformat.OutputFormat(format) + if ok := flagFmt.IsValid(); !ok { + errUtils.CheckErrorPrintAndExit(fmt.Errorf("%v is not a valid format choose from the following: %v", format, outputformat.GetArgumentChoiceText()), "", "") + } + cliConfig.Format = flagFmt }
♻️ Duplicate comments (1)
pkg/config/config_test.go (1)
669-870
: Don’t reimplement env→config merge in tests; exercise shared helper and add more casesThese tests manually mirror env binding (BindEnv + direct struct writes). This can drift from prod behavior. Prefer a shared helper used by both prod and tests, or call the actual init path.
Also, consider cases for boolean synonyms (on/off/yes/no/TRUE/FALSE) for pager and color to cover “smart parsing,” and use t.Setenv for brevity.
Apply (example adjustments):
- // Apply environment variables to config - if envPager := v.GetString("settings.terminal.pager"); envPager != "" { - atmosConfig.Settings.Terminal.Pager = envPager - } - if v.IsSet("settings.terminal.no_color") { - atmosConfig.Settings.Terminal.NoColor = v.GetBool("settings.terminal.no_color") - if atmosConfig.Settings.Terminal.NoColor { - atmosConfig.Settings.Terminal.Color = false - } - } - if v.IsSet("settings.terminal.color") && !atmosConfig.Settings.Terminal.NoColor { - atmosConfig.Settings.Terminal.Color = v.GetBool("settings.terminal.color") - } + // Prefer invoking the real merge/binding path or a shared helper to avoid duplication: + // e.g., bindEnvAndMergeIntoConfig(v, atmosConfig)Optionally, add table rows for:
- PAGER=on/off, ATMOS_PAGER=on/off
- ATMOS_COLOR=on/TRUE vs NO_COLOR=0/false
- Mixed-case inputs.
And replace manual env save/restore with t.Setenv.
🧹 Nitpick comments (7)
website/docs/cli/global-flags.mdx (4)
66-82
: Tighten pager wording.Clarify “default settings” to “configured/default pager.”
- - `--pager` (no value): Enable pager with default settings + - `--pager` (no value): Enable pager using the configured/default pager
321-322
: Fix misleading comment about PAGER=cat.It doesn’t disable the pager; it effectively bypasses pagination.
-export PAGER=cat # Disables paging in Atmos and other tools that respect PAGER +export PAGER=cat # Effectively disables pagination by piping output through cat
63-64
: Use proper Markdown links for no-color.org.Improves rendering and consistency.
- - The `NO_COLOR` env var follows the standard from https://no-color.org/ + - The `NO_COLOR` env var follows the standard from [no-color.org](https://no-color.org/)- - `NO_COLOR` is a standard environment variable supported by many CLI tools (https://no-color.org/) + - `NO_COLOR` is a standard environment variable supported by many CLI tools ([no-color.org](https://no-color.org/))Also applies to: 218-219
329-336
: Clarify pipe behavior precedence.Make explicit that piping overrides flag/env.
-When output is piped to another command, Atmos automatically disables color output and pager to ensure compatibility: +When output is piped to another command, Atmos automatically disables color output and pager (even if enabled via flag/env) to ensure compatibility:internal/exec/describe_component_test.go (3)
43-73
: Drop duplicate “(legacy test)” cases and align namesThe YAML/JSON “(legacy test)” entries duplicate the preceding two cases and add noise. If no legacy-specific code path exists anymore, remove them.
- { - name: "Test with YAML format (legacy test)", - params: DescribeComponentParams{ - Component: "component-1", - Stack: "nonprod", - Format: "yaml", - }, - }, - { - name: "Test with JSON format (legacy test)", - params: DescribeComponentParams{ - Component: "component-1", - Stack: "nonprod", - Format: "json", - }, - },
15-15
: Rename test: it no longer validates pager behaviorPager is global now. Suggest renaming for accuracy.
-func TestExecuteDescribeComponentCmd_Success_YAMLWithPager(t *testing.T) { +func TestExecuteDescribeComponentCmd_Success_Formats(t *testing.T) {
111-115
: Assert the concrete error type for invalid formatStrengthen the check with ErrorAs to ensure DescribeConfigFormatError is returned.
- if test.expectedError { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } + if test.expectedError { + var ferr DescribeConfigFormatError + assert.Error(t, err) + assert.ErrorAs(t, err, &ferr) + } else { + assert.NoError(t, err) + }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (9)
cmd/describe_component.go
(0 hunks)cmd/root.go
(3 hunks)cmd/validate_editorconfig.go
(1 hunks)internal/exec/describe_component.go
(0 hunks)internal/exec/describe_component_test.go
(2 hunks)pkg/config/config.go
(1 hunks)pkg/config/config_test.go
(1 hunks)pkg/schema/schema.go
(2 hunks)website/docs/cli/global-flags.mdx
(1 hunks)
💤 Files with no reviewable changes (2)
- internal/exec/describe_component.go
- cmd/describe_component.go
🚧 Files skipped from review as they are similar to previous changes (3)
- pkg/config/config.go
- pkg/schema/schema.go
- cmd/root.go
🧰 Additional context used
📓 Path-based instructions (4)
cmd/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
cmd/*.go
: Implement each Cobra command in a separate file under the cmd/ directory
Use kebab-case for command-line flags
Provide comprehensive help text for all commands and flags
Include examples in command help
Provide meaningful feedback to users in command implementation
Include progress indicators for long-running operations
Provide clear error messages to users
Include troubleshooting hints when appropriate
Log detailed errors for debugging
Files:
cmd/validate_editorconfig.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go
: Use Viper for managing configuration, environment variables, and flags
Use interfaces for external dependencies to facilitate mocking
All code must pass golangci-lint checks
Follow Go's error handling idioms
Use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider using a custom error type for domain-specific errors
Follow standard Go coding style
Use gofmt and goimports to format code
Prefer short, descriptive variable names
Use snake_case for environment variables
Document all exported functions, types, and methods
Document complex logic with inline comments
Follow Go's documentation conventions
Use Viper for configuration management
Support configuration via files, environment variables, and flags
Follow the precedence order: flags > environment variables > config file > defaults
Files:
cmd/validate_editorconfig.go
pkg/config/config_test.go
internal/exec/describe_component_test.go
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go
: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for testing multiple scenarios
Include integration tests for command flows
Test CLI end-to-end when possible
Use test fixtures for complex inputs
Consider using testify/mock for creating mock implementations
Files:
pkg/config/config_test.go
internal/exec/describe_component_test.go
website/**
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
website/**
: Update website documentation in the website/ directory when adding new features
Follow the website's documentation structure and style
Keep website code in the website/ directory
Follow the existing website architecture and style
Document new features on the website
Include examples and use cases in website documentation
Files:
website/docs/cli/global-flags.mdx
🧠 Learnings (19)
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2024-10-20T13:12:46.499Z
Learnt from: haitham911
PR: cloudposse/atmos#736
File: pkg/config/const.go:6-6
Timestamp: 2024-10-20T13:12:46.499Z
Learning: In `cmd/cmd_utils.go`, it's acceptable to have hardcoded references to `atmos.yaml` in logs, and it's not necessary to update them to use the `CliConfigFileName` constant.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2024-10-28T01:51:30.811Z
Learnt from: osterman
PR: cloudposse/atmos#727
File: internal/exec/terraform_clean.go:329-332
Timestamp: 2024-10-28T01:51:30.811Z
Learning: In the Atmos Go code, when deleting directories or handling file paths (e.g., in `terraform_clean.go`), always resolve the absolute path using `filepath.Abs` and use the logger `u.LogWarning` for logging messages instead of using `fmt.Printf`.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2025-02-06T13:38:07.216Z
Learnt from: Listener430
PR: cloudposse/atmos#984
File: internal/exec/copy_glob.go:0-0
Timestamp: 2025-02-06T13:38:07.216Z
Learning: The `u.LogTrace` function in the `cloudposse/atmos` repository accepts `atmosConfig` as its first parameter, followed by the message string.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2025-01-30T16:56:43.004Z
Learnt from: mcalhoun
PR: cloudposse/atmos#980
File: pkg/utils/log_utils.go:62-63
Timestamp: 2025-01-30T16:56:43.004Z
Learning: In pkg/utils/log_utils.go, LogTrace is intentionally redirected to LogDebug since charmbracelet logger doesn't support Trace level, maintaining backward compatibility with the original LogTrace functionality.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2024-12-11T18:40:12.808Z
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.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2024-11-10T19:28:17.365Z
Learnt from: osterman
PR: cloudposse/atmos#768
File: internal/exec/vendor_utils.go:0-0
Timestamp: 2024-11-10T19:28:17.365Z
Learning: When TTY is not supported, log the downgrade message at the Warn level using `u.LogWarning(cliConfig, ...)` instead of `fmt.Println`.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2024-12-13T15:28:13.630Z
Learnt from: Listener430
PR: cloudposse/atmos#844
File: cmd/version.go:34-44
Timestamp: 2024-12-13T15:28:13.630Z
Learning: In `cmd/version.go`, when handling the `--check` flag in the `versionCmd`, avoid using `CheckForAtmosUpdateAndPrintMessage(cliConfig)` as it updates the cache timestamp, which may not be desired in this context.
Applied to files:
cmd/validate_editorconfig.go
📚 Learning: 2025-04-23T15:02:50.246Z
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.
Applied to files:
pkg/config/config_test.go
📚 Learning: 2025-08-15T14:43:41.030Z
Learnt from: aknysh
PR: cloudposse/atmos#1352
File: pkg/store/artifactory_store_test.go:108-113
Timestamp: 2025-08-15T14:43:41.030Z
Learning: In test files for the atmos project, it's acceptable to ignore errors from os.Setenv/Unsetenv operations during test environment setup and teardown, as these are controlled test scenarios.
Applied to files:
pkg/config/config_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Consider using testify/mock for creating mock implementations
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-07-05T20:59:02.914Z
Learnt from: aknysh
PR: cloudposse/atmos#1363
File: internal/exec/template_utils.go:18-18
Timestamp: 2025-07-05T20:59:02.914Z
Learning: In the Atmos project, gomplate v4 is imported with a blank import (`_ "github.com/hairyhenderson/gomplate/v4"`) alongside v3 imports to resolve AWS SDK version conflicts. V3 uses older AWS SDK versions that conflict with newer AWS modules used by Atmos. A full migration to v4 requires extensive refactoring due to API changes and should be handled in a separate PR.
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*.go : Use interfaces for external dependencies to facilitate mocking
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Use table-driven tests for testing multiple scenarios
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Test both happy paths and error conditions
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Include integration tests for command flows
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2024-12-12T17:13:53.409Z
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Applied to files:
website/docs/cli/global-flags.mdx
📚 Learning: 2025-05-22T19:58:32.988Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected.go:122-123
Timestamp: 2025-05-22T19:58:32.988Z
Learning: The "pager" flag is defined as a PersistentFlag at the describe command level in cmd/describe.go, making it available to all subcommands including describeAffectedCmd without needing to redeclare it.
Applied to files:
website/docs/cli/global-flags.mdx
🧬 Code graph analysis (1)
pkg/config/config_test.go (1)
pkg/schema/schema.go (4)
AtmosConfiguration
(26-61)Settings
(853-857)AtmosSettings
(245-265)Terminal
(204-212)
🪛 LanguageTool
website/docs/cli/global-flags.mdx
[grammar] ~7-~7: There might be a mistake here.
Context: ...Intro from '@site/src/components/Intro'; import Note from '@site/src/components/N...
(QB_NEW_EN)
[grammar] ~190-~190: There might be a mistake here.
Context: ...1. Command-line flags (highest priority) 2. Environment variables 3. Configuration f...
(QB_NEW_EN)
[grammar] ~191-~191: There might be a mistake here.
Context: ...ghest priority) 2. Environment variables 3. Configuration file (atmos.yaml
) 4. Def...
(QB_NEW_EN)
[grammar] ~192-~192: There might be a mistake here.
Context: ...les 3. Configuration file (atmos.yaml
) 4. Default values (lowest priority) ### Co...
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Lint (golangci)
- GitHub Check: Analyze (go)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: website-deploy-preview
- GitHub Check: Summary
🔇 Additional comments (5)
website/docs/cli/global-flags.mdx (2)
72-78
: Nice: command-with-args support is clearly documented.Explicitly calling out “any non-boolean value is a command” plus quoting examples matches how users expect to pass pager args.
16-20
: Global flags wiring and defaults match documentation.cmd/validate_editorconfig.go (1)
114-120
: Good: use constant for trace levelReplacing the string literal with
u.LogLevelTrace
avoids typos and centralizes semantics.pkg/config/config_test.go (2)
531-611
: Solid pager/no-color flag parsing coverageGood table-driven tests validating --pager forms and interaction with --no-color.
613-667
: Verify NoColor effects; looks correctAsserting Color=false when --no-color is set matches schema semantics.
This change reduces Atmos output verbosity by changing the default log level from Info to Warning. Also fixes global flags documentation by removing non-global flag sections. - Change default log level from "Info" to "Warning" in config files - Update all test files to use "Warning" instead of "Info" as default - Remove non-global flag sections from global-flags.mdx documentation - Update documentation examples to reflect new default log level 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Warning This PR exceeds the recommended limit of 1,000 lines.Large PRs are difficult to review and may be rejected due to their size. Please verify that this PR does not address multiple issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (7)
cmd/packer_output_test.go (1)
20-24
: Restore logger output to avoid leaking test state.
log.SetOutput(w)
isn’t reverted; subsequent tests may write to a closed pipe.// Restore std - err = w.Close() + // Restore logger output before closing the pipe to avoid writes to a closed fd + log.SetOutput(os.Stderr) + err = w.Close() assert.NoError(t, err) os.Stdout = oldStdAlso applies to: 29-33
internal/exec/packer_test.go (3)
34-39
: Reset logger output after capture in Validate test.
log.SetOutput(w)
isn’t restored; can affect other tests.os.Stdout = w log.SetOutput(w) packerFlags := PackerFlags{} err := ExecutePacker(&info, &packerFlags) assert.NoError(t, err) // Restore std - err = w.Close() + // Restore logger output before closing the writer + log.SetOutput(os.Stderr) + err = w.Close() assert.NoError(t, err) os.Stdout = oldStdAlso applies to: 45-48
82-88
: Reset logger output after capture in Inspect test.Same leak risk here.
os.Stdout = w log.SetOutput(w) packerFlags := PackerFlags{} err := ExecutePacker(&info, &packerFlags) assert.NoError(t, err) // Restore std - err = w.Close() + log.SetOutput(os.Stderr) + err = w.Close() assert.NoError(t, err) os.Stdout = oldStdAlso applies to: 92-96
124-131
: Reset logger output after capture in Version test.Restore logger output to default.
os.Stdout = w log.SetOutput(w) packerFlags := PackerFlags{} err := ExecutePacker(&info, &packerFlags) assert.NoError(t, err) // Restore std - err = w.Close() + log.SetOutput(os.Stderr) + err = w.Close() assert.NoError(t, err) os.Stdout = oldStdAlso applies to: 134-138
pkg/config/default.go (1)
63-67
: Disable default pager: update pkg/config/default.go (line 65) toPager: ""
and change in pkg/config/load.go (line 139)v.SetDefault("settings.terminal.pager", true)
→false
to align with disabled-by-default intent.cmd/root_test.go (1)
36-39
: Restore logger output after test.Prevent global logger from remaining pointed at the buffer.
// Create a buffer to capture the output var buf bytes.Buffer log.SetOutput(&buf) + defer log.SetOutput(os.Stderr)
Also applies to: 55-56
internal/exec/describe_component_test.go (1)
38-41
: Actually assert yq filtering (and cover no-pager + query).The “query” scenario doesn’t validate filtering:
evaluateYqExpression
returns the unmodified map and pager content isn’t asserted. Add a per-subtest yq stub and assert filtered data when pager is off. Also makeprintOrWriteToFile
query-aware.Apply:
@@ - evaluateYqExpression: func(atmosConfig *schema.AtmosConfiguration, data any, yq string) (any, error) { - return data, nil - }, + evaluateYqExpression: func(atmosConfig *schema.AtmosConfiguration, data any, yq string) (any, error) { + return data, nil + }, @@ - if test.expectPager { + if test.expectPager { mockPager := pager.NewMockPageCreator(ctrl) if test.expectedError && test.params.Format == "invalid-format" { // The pager won't be called because viewConfig will return error before reaching pageCreator } else { mockPager.EXPECT().Run("component-1", gomock.Any()).Return(nil).Times(1) } mockedExec.pageCreator = mockPager } else { // For non-pager tests, we don't need to mock the pager as it won't be called mockedExec.pageCreator = nil } @@ - // Mock the initCliConfig to return a config with the test's pager setting + // Mock the initCliConfig to return a config with the test's pager setting mockedExec.initCliConfig = func(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error) { return schema.AtmosConfiguration{ Settings: schema.AtmosSettings{ Terminal: schema.Terminal{ Pager: test.pagerSetting, }, }, }, nil } + // Override yq evaluator per test: simulate filtering when a query is provided + mockedExec.evaluateYqExpression = func(atmosConfig *schema.AtmosConfiguration, data any, yq string) (any, error) { + if yq != "" { + return "component-1", nil + } + return data, nil + } @@ - // Mock printOrWriteToFile - this should only be called when pager is disabled or fails + // Mock printOrWriteToFile - this should only be called when pager is disabled or fails mockedExec.printOrWriteToFile = func(atmosConfig *schema.AtmosConfiguration, format string, file string, data any) error { printOrWriteToFileCalled = true if test.expectedError && test.params.Format == "invalid-format" { return DescribeConfigFormatError{format: "invalid-format"} } assert.Equal(t, test.params.Format, format) assert.Equal(t, "", file) - assert.Equal(t, map[string]any{ - "component": "component-1", - "stack": "nonprod", - }, data) + if test.params.Query != "" { + assert.Equal(t, "component-1", data) + } else { + assert.Equal(t, map[string]any{ + "component": "component-1", + "stack": "nonprod", + }, data) + } return nil } @@ }, } + // Add coverage for "query without pager" to prove filtered output hits print path + tests = append(tests, struct { + name string + params DescribeComponentParams + pagerSetting string + expectPager bool + expectedError bool + }{ + name: "Test query without pager", + params: DescribeComponentParams{ + Component: "component-1", + Stack: "nonprod", + Format: "json", + Query: ".component", + }, + pagerSetting: "off", + expectPager: false, + })Also applies to: 117-126, 131-141, 142-155, 112-112
🧹 Nitpick comments (5)
cmd/packer_output_test.go (1)
17-19
: Align log level with new default.Env sets "Warning" but the logger is set to Info. Switch to Warn to avoid confusion.
- log.SetLevel(log.InfoLevel) + log.SetLevel(log.WarnLevel)internal/exec/packer_test.go (1)
21-22
: Optional: make logger level match env (Warn).Minor consistency tweak.
- log.SetLevel(log.InfoLevel) + log.SetLevel(log.WarnLevel)Also applies to: 69-70, 117-118, 159-160, 183-184
cmd/root_test.go (1)
22-24
: Optional: drop the initial Warning set.This is overridden by
t.Setenv("ATMOS_LOGS_LEVEL", "Debug")
later; the early set is redundant.- err = os.Setenv("ATMOS_LOGS_LEVEL", "Warning") - assert.NoError(t, err, "Setting 'ATMOS_LOGS_LEVEL' environment variable should execute without error")internal/exec/describe_component_test.go (1)
17-21
: Rename test to reflect the matrix it runs.Covers YAML/JSON, pager on/off, errors—not just “YAMLWithPager”.
-func TestExecuteDescribeComponentCmd_Success_YAMLWithPager(t *testing.T) { +func TestExecuteDescribeComponentCmd_PagerMatrix(t *testing.T) {website/docs/cli/global-flags.mdx (1)
66-72
: Tighten wording: “configured/default pager”.Make it explicit that
--pager
with no value uses the configured (or default) pager command.- - `--pager` (no value): Enable pager with default settings + - `--pager` (no value): Enable pager using the configured/default pager
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (14)
cmd/packer_init_test.go
(1 hunks)cmd/packer_inspect_test.go
(1 hunks)cmd/packer_output_test.go
(1 hunks)cmd/packer_validate_test.go
(1 hunks)cmd/packer_version_test.go
(1 hunks)cmd/root.go
(3 hunks)cmd/root_test.go
(1 hunks)internal/exec/describe_component_test.go
(2 hunks)internal/exec/packer_output_test.go
(1 hunks)internal/exec/packer_test.go
(5 hunks)pkg/config/default.go
(1 hunks)pkg/config/load.go
(2 hunks)pkg/config/load_config_test.go
(3 hunks)website/docs/cli/global-flags.mdx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/config/load.go
- cmd/root.go
🧰 Additional context used
📓 Path-based instructions (4)
cmd/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
cmd/*.go
: Implement each Cobra command in a separate file under the cmd/ directory
Use kebab-case for command-line flags
Provide comprehensive help text for all commands and flags
Include examples in command help
Provide meaningful feedback to users in command implementation
Include progress indicators for long-running operations
Provide clear error messages to users
Include troubleshooting hints when appropriate
Log detailed errors for debugging
Files:
cmd/packer_output_test.go
cmd/root_test.go
cmd/packer_init_test.go
cmd/packer_version_test.go
cmd/packer_inspect_test.go
cmd/packer_validate_test.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go
: Use Viper for managing configuration, environment variables, and flags
Use interfaces for external dependencies to facilitate mocking
All code must pass golangci-lint checks
Follow Go's error handling idioms
Use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider using a custom error type for domain-specific errors
Follow standard Go coding style
Use gofmt and goimports to format code
Prefer short, descriptive variable names
Use snake_case for environment variables
Document all exported functions, types, and methods
Document complex logic with inline comments
Follow Go's documentation conventions
Use Viper for configuration management
Support configuration via files, environment variables, and flags
Follow the precedence order: flags > environment variables > config file > defaults
Files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/root_test.go
pkg/config/default.go
cmd/packer_init_test.go
cmd/packer_version_test.go
pkg/config/load_config_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
internal/exec/describe_component_test.go
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go
: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for testing multiple scenarios
Include integration tests for command flows
Test CLI end-to-end when possible
Use test fixtures for complex inputs
Consider using testify/mock for creating mock implementations
Files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/root_test.go
cmd/packer_init_test.go
cmd/packer_version_test.go
pkg/config/load_config_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
internal/exec/describe_component_test.go
website/**
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
website/**
: Update website documentation in the website/ directory when adding new features
Follow the website's documentation structure and style
Keep website code in the website/ directory
Follow the existing website architecture and style
Document new features on the website
Include examples and use cases in website documentation
Files:
website/docs/cli/global-flags.mdx
🧠 Learnings (20)
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: The atmos codebase has a custom extension to *testing.T that provides a Chdir method, allowing test functions to call t.Chdir() to change working directories during tests. This is used consistently across test files in the codebase.
Applied to files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/packer_init_test.go
cmd/packer_version_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
📚 Learning: 2025-08-15T14:43:41.030Z
Learnt from: aknysh
PR: cloudposse/atmos#1352
File: pkg/store/artifactory_store_test.go:108-113
Timestamp: 2025-08-15T14:43:41.030Z
Learning: In test files for the atmos project, it's acceptable to ignore errors from os.Setenv/Unsetenv operations during test environment setup and teardown, as these are controlled test scenarios.
Applied to files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/root_test.go
cmd/packer_init_test.go
cmd/packer_version_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: In the atmos codebase, t.Chdir() is a valid method that can be called on *testing.T objects. This functionality is implemented through custom testing framework extensions and is used consistently throughout the test suite for changing working directories during tests.
Applied to files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/packer_version_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: In the atmos codebase, t.Chdir() is a valid method call on *testing.T objects and works correctly for changing directories in tests. This is implemented through custom testing framework extensions and is used consistently throughout the test suite.
Applied to files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/packer_version_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: In the atmos codebase, t.Chdir() is a valid method call on *testing.T objects and works correctly for changing directories in tests.
Applied to files:
cmd/packer_output_test.go
internal/exec/packer_output_test.go
cmd/packer_version_test.go
cmd/packer_inspect_test.go
internal/exec/packer_test.go
cmd/packer_validate_test.go
📚 Learning: 2024-10-28T01:51:30.811Z
Learnt from: osterman
PR: cloudposse/atmos#727
File: internal/exec/terraform_clean.go:329-332
Timestamp: 2024-10-28T01:51:30.811Z
Learning: In the Atmos Go code, when deleting directories or handling file paths (e.g., in `terraform_clean.go`), always resolve the absolute path using `filepath.Abs` and use the logger `u.LogWarning` for logging messages instead of using `fmt.Printf`.
Applied to files:
cmd/packer_output_test.go
cmd/packer_version_test.go
pkg/config/load_config_test.go
cmd/packer_inspect_test.go
cmd/packer_validate_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Test both happy paths and error conditions
Applied to files:
internal/exec/packer_output_test.go
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Use table-driven tests for testing multiple scenarios
Applied to files:
internal/exec/packer_output_test.go
internal/exec/describe_component_test.go
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Applied to files:
internal/exec/packer_output_test.go
cmd/root_test.go
📚 Learning: 2024-10-31T19:25:41.298Z
Learnt from: osterman
PR: cloudposse/atmos#727
File: internal/exec/terraform_clean.go:233-235
Timestamp: 2024-10-31T19:25:41.298Z
Learning: When specifying color values in functions like `confirmDeleteTerraformLocal` in `internal/exec/terraform_clean.go`, avoid hardcoding color values. Instead, use predefined color constants or allow customization through configuration settings to improve accessibility and user experience across different terminals and themes.
Applied to files:
cmd/root_test.go
📚 Learning: 2025-04-23T15:02:50.246Z
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.
Applied to files:
cmd/root_test.go
📚 Learning: 2024-11-10T19:28:17.365Z
Learnt from: osterman
PR: cloudposse/atmos#768
File: internal/exec/vendor_utils.go:0-0
Timestamp: 2024-11-10T19:28:17.365Z
Learning: When TTY is not supported, log the downgrade message at the Warn level using `u.LogWarning(cliConfig, ...)` instead of `fmt.Println`.
Applied to files:
pkg/config/default.go
pkg/config/load_config_test.go
📚 Learning: 2024-12-11T18:40:12.808Z
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.
Applied to files:
cmd/packer_init_test.go
📚 Learning: 2024-12-13T15:28:13.630Z
Learnt from: Listener430
PR: cloudposse/atmos#844
File: cmd/version.go:34-44
Timestamp: 2024-12-13T15:28:13.630Z
Learning: In `cmd/version.go`, when handling the `--check` flag in the `versionCmd`, avoid using `CheckForAtmosUpdateAndPrintMessage(cliConfig)` as it updates the cache timestamp, which may not be desired in this context.
Applied to files:
cmd/packer_version_test.go
📚 Learning: 2024-10-20T13:12:46.499Z
Learnt from: haitham911
PR: cloudposse/atmos#736
File: pkg/config/const.go:6-6
Timestamp: 2024-10-20T13:12:46.499Z
Learning: In `cmd/cmd_utils.go`, it's acceptable to have hardcoded references to `atmos.yaml` in logs, and it's not necessary to update them to use the `CliConfigFileName` constant.
Applied to files:
pkg/config/load_config_test.go
📚 Learning: 2024-12-12T15:17:45.245Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: examples/demo-atmos.d/atmos.d/tools/helmfile.yml:10-10
Timestamp: 2024-12-12T15:17:45.245Z
Learning: In `examples/demo-atmos.d/atmos.d/tools/helmfile.yml`, when suggesting changes to `kubeconfig_path`, ensure that the values use valid Go template syntax.
Applied to files:
pkg/config/load_config_test.go
📚 Learning: 2024-12-12T17:13:53.409Z
Learnt from: RoseSecurity
PR: cloudposse/atmos#848
File: pkg/utils/doc_utils.go:19-22
Timestamp: 2024-12-12T17:13:53.409Z
Learning: In `pkg/utils/doc_utils.go`, the `DisplayDocs` function uses the `PAGER` environment variable, which is intentionally user-configurable to allow users to specify custom pager commands that fit their workflow; adding validation to restrict it is not desired.
Applied to files:
website/docs/cli/global-flags.mdx
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Use test fixtures for complex inputs
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-01-19T23:13:50.429Z
Learnt from: aknysh
PR: cloudposse/atmos#943
File: internal/exec/describe_config.go:37-37
Timestamp: 2025-01-19T23:13:50.429Z
Learning: When reviewing pointer usage with `EvaluateYqExpression`, check if the `atmosConfig` parameter is already a pointer (e.g., when returned by `InitCliConfig`) to avoid suggesting unnecessary address-of operations.
Applied to files:
internal/exec/describe_component_test.go
📚 Learning: 2025-07-01T02:22:25.901Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-07-01T02:22:25.901Z
Learning: Applies to **/*_test.go : Consider using testify/mock for creating mock implementations
Applied to files:
internal/exec/describe_component_test.go
🧬 Code graph analysis (1)
internal/exec/describe_component_test.go (4)
internal/exec/describe_component.go (1)
DescribeComponentParams
(14-23)pkg/pager/mock_pager.go (1)
NewMockPageCreator
(25-29)pkg/schema/schema.go (4)
AtmosConfiguration
(26-61)Settings
(853-857)AtmosSettings
(245-265)Terminal
(204-212)internal/exec/describe_config.go (1)
DescribeConfigFormatError
(16-18)
🪛 LanguageTool
website/docs/cli/global-flags.mdx
[grammar] ~7-~7: There might be a mistake here.
Context: ...Intro from '@site/src/components/Intro'; import Note from '@site/src/components/N...
(QB_NEW_EN)
[grammar] ~151-~151: There might be a mistake here.
Context: ...1. Command-line flags (highest priority) 2. Environment variables 3. Configuration f...
(QB_NEW_EN)
[grammar] ~152-~152: There might be a mistake here.
Context: ...ghest priority) 2. Environment variables 3. Configuration file (atmos.yaml
) 4. Def...
(QB_NEW_EN)
[grammar] ~153-~153: There might be a mistake here.
Context: ...les 3. Configuration file (atmos.yaml
) 4. Default values (lowest priority) ### Co...
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: [mock-macos] tests/fixtures/scenarios/complete
- GitHub Check: [mock-windows] examples/demo-atlantis
- GitHub Check: [mock-windows] examples/demo-component-versions
- GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
- GitHub Check: [mock-windows] examples/demo-vendoring
- GitHub Check: [k3s] demo-helmfile
- GitHub Check: [localstack] demo-localstack
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: Summary
🔇 Additional comments (5)
internal/exec/packer_output_test.go (1)
18-18
: LGTM: test updated to Warning levelMatches the new default log-level semantics. No other concerns here.
internal/exec/packer_test.go (1)
20-21
: LGTM: tests updated to Warning level.Matches the new default and keeps expectations consistent.
Also applies to: 68-69, 116-118, 158-160, 182-184
pkg/config/default.go (1)
81-83
: LGTM: default log level → Warning.Consistent with updated tests and reduced verbosity.
pkg/config/load_config_test.go (1)
31-32
: LGTM: expectations updated to Warning.Matches the new default and validates merge precedence correctly.
Also applies to: 83-84, 102-103
internal/exec/describe_component_test.go (1)
117-141
: Nice: clean pager mocking and global config injection.Good use of gomock and driving behavior via
Terminal.Pager
. LGTM.
t.Setenv("ATMOS_LOGS_LEVEL", "Warning") | ||
log.SetLevel(log.InfoLevel) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use Warn level to match ATMOS_LOGS_LEVEL
The test sets env to Warning but forces the logger to Info.
- t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
- log.SetLevel(log.InfoLevel)
+ t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
+ log.SetLevel(log.WarnLevel)
📝 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.
t.Setenv("ATMOS_LOGS_LEVEL", "Warning") | |
log.SetLevel(log.InfoLevel) | |
t.Setenv("ATMOS_LOGS_LEVEL", "Warning") | |
log.SetLevel(log.WarnLevel) |
🤖 Prompt for AI Agents
In cmd/packer_init_test.go around lines 14 to 16, the test sets ATMOS_LOGS_LEVEL
to "Warning" but then forces the logger to Info; change the logger level to
log.WarnLevel (or derive and set it from the ATMOS_LOGS_LEVEL env var) so the
logger level matches the environment variable used in the test.
t.Setenv("ATMOS_LOGS_LEVEL", "Warning") | ||
log.SetLevel(log.InfoLevel) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match log level to env and restore logger output
Prevent divergence (Warning vs Info) and avoid logging to a closed pipe after w.Close()
.
- t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
- log.SetLevel(log.InfoLevel)
+ t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
+ log.SetLevel(log.WarnLevel)
@@
os.Stdout = oldStd
+ log.SetOutput(os.Stderr)
Also applies to: 20-24, 29-33
🤖 Prompt for AI Agents
In cmd/packer_inspect_test.go around lines 17-19 (also apply same fixes to 20-24
and 29-33): the test sets ATMOS_LOGS_LEVEL to "Warning" but sets the logger to
Info, and the test changes log output to a pipe without restoring it before
closing the writer causing writes to a closed pipe; change log.SetLevel to
log.WarnLevel to match the env var, capture the original log output before
redirecting, and restore log.SetOutput(original) (and optionally restore level)
before calling w.Close() so no writes occur after the pipe is closed.
t.Setenv("ATMOS_LOGS_LEVEL", "Warning") | ||
log.SetLevel(log.InfoLevel) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align log level with env and restore logger output to avoid writes to a closed pipe
Env sets Warning but test forces Info and never restores log output. This can mask behavior and cause flakiness when w
is closed.
Apply:
- t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
- log.SetLevel(log.InfoLevel)
+ t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
+ log.SetLevel(log.WarnLevel)
@@
os.Stdout = oldStd
+ // Restore logger output to default stderr to avoid writing to a closed pipe.
+ log.SetOutput(os.Stderr)
Also applies to: 20-24, 29-33
🤖 Prompt for AI Agents
In cmd/packer_validate_test.go around lines 17-19 (and similarly at 20-24 and
29-33), the test sets ATMOS_LOGS_LEVEL=Warning but then forces the logger to
InfoLevel and redirects logger output without restoring it, which can hide
expected log-level behavior and cause panics when the temporary writer is
closed; change the test to set the logger level to match the environment
(Warning), and if you redirect log output for assertions, capture the original
output and defer restoring it (and defer resetting the logger level if modified)
so the test cleans up and does not write to a closed pipe.
t.Setenv("ATMOS_LOGS_LEVEL", "Warning") | ||
log.SetLevel(log.InfoLevel) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Keep logger consistent with Warning and restore output target
Align level with env and reset output to stderr after capture.
- t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
- log.SetLevel(log.InfoLevel)
+ t.Setenv("ATMOS_LOGS_LEVEL", "Warning")
+ log.SetLevel(log.WarnLevel)
@@
os.Stdout = oldStd
+ log.SetOutput(os.Stderr)
Also applies to: 20-24, 29-33
🤖 Prompt for AI Agents
In cmd/packer_version_test.go around lines 17-19 (and similarly for ranges 20-24
and 29-33), the test sets ATMOS_LOGS_LEVEL to "Warning" but sets the logger to
InfoLevel and does not restore the logger output after capturing; change the
logger level to Warning to match the environment, and after any output capture
restore the logger's output target back to os.Stderr so subsequent tests/logs
are not affected.
<dt>`--logs-level`</dt> | ||
<dd> | ||
Set the logging level for Atmos operations. | ||
- Options: `Trace`, `Debug`, `Info`, `Warning`, `Off` | ||
- Default: `Warning` | ||
- Can also use `ATMOS_LOGS_LEVEL` environment variable | ||
</dd> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify default log level and accepted values match code.
Confirm “Warning” is the default and the set {Trace, Debug, Info, Warning, Off} is canonical.
🏁 Script executed:
#!/bin/bash
# Check default logs-level and accepted values in code
rg -nP -C3 '\b(logs[-_.]level|Logs\.Level)\b' --type=go
rg -nP -C2 '\b(Trace|Debug|Info|Warn|Warning|Error|Off)\b' --type=go
rg -nP -C3 'SetDefault\((?:"logs\.level"|`logs\.level`),\s*"(.*?)"\)' --type=go
Length of output: 284113
Mismatch: docs default (Warning
) vs CLI flag default (Info
) — accepted levels confirmed
- Accepted values confirmed: Trace, Debug, Info, Warning, Off (pkg/logger/logger.go; validated in pkg/logger/logger_test.go).
- Default conflict: docs say
Warning
(website/docs/cli/global-flags.mdx) but code registers CLI flag default asInfo
(cmd/root.go:206) while Viper/config defaults areWarning
(pkg/config/load.go:136, pkg/config/default.go:82). - Action: align defaults — either change cmd/root.go to use
Warning
or update docs/config toInfo
. Update the doc and the flag or config to the chosen single source of truth (see files above).
export NO_COLOR=1 # Disables color in Atmos and other NO_COLOR-compliant tools | ||
export PAGER=cat # Disables paging in Atmos and other tools that respect PAGER | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix inaccurate note about PAGER=cat.
PAGER=cat
doesn’t “disable” paging; it makes the pager a pass-through. Reword to avoid confusion.
-export PAGER=cat # Disables paging in Atmos and other tools that respect PAGER
+export PAGER=cat # Uses 'cat' as the pager (effectively no paging; output goes straight to stdout)
📝 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.
export NO_COLOR=1 # Disables color in Atmos and other NO_COLOR-compliant tools | |
export PAGER=cat # Disables paging in Atmos and other tools that respect PAGER | |
export NO_COLOR=1 # Disables color in Atmos and other NO_COLOR-compliant tools | |
export PAGER=cat # Uses 'cat' as the pager (effectively no paging; output goes straight to stdout) |
🤖 Prompt for AI Agents
In website/docs/cli/global-flags.mdx around lines 281 to 283, the note
incorrectly states that setting PAGER=cat "disables paging"; update the wording
to say it makes the pager a pass-through so output is shown without interactive
paging. Change the second line’s comment to clarify that PAGER=cat causes tools
that use the PAGER environment variable to write output directly (no interactive
pager), rather than claiming it disables paging globally.
Summary
--pager
flag with smart parsing (true/false/command)Breaking Changes
pager: true
toatmos.yaml
or use--pager
flagTest Plan
atmos describe stacks --pager
to verify pager enablesatmos describe stacks
to verify pager is disabled by defaultATMOS_PAGER=true atmos describe stacks
enables pager--pager=false
explicitly disables pagergo test ./pkg/pager/... ./pkg/schema/... ./pkg/config/...
Changes
pkg/pager/pager.go
)--pager
flag to all commands (cmd/root.go
)color
field to terminal settings (pkg/schema/schema.go
)ATMOS_COLOR
andCOLOR
environment variableswebsite/docs/cli/global-flags.mdx
)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores
Documentation
Tests