Skip to content

Display CLI config aliases in separate ALIASES help section#1867

Merged
aknysh merged 6 commits intomainfrom
osterman/cli-alias-help-display
Dec 14, 2025
Merged

Display CLI config aliases in separate ALIASES help section#1867
aknysh merged 6 commits intomainfrom
osterman/cli-alias-help-display

Conversation

@osterman
Copy link
Copy Markdown
Member

@osterman osterman commented Dec 12, 2025

what

  • CLI aliases defined in atmos.yaml now appear in a dedicated "ALIASES" section in --help output
  • Separates user-defined command shortcuts from regular commands for improved help clarity
  • Maintains distinction between built-in command aliases and CLI config aliases

why

Users reported that aliases added via CLI config (atmos.yaml) appeared mixed with regular commands in the "AVAILABLE COMMANDS" section, making help output less clear. Creating a dedicated "ALIASES" section improves UX by clearly distinguishing shortcuts from actual commands.

implementation

  • Mark config aliases with "configAlias" annotation in processCommandAliases()
  • Add isConfigAlias() helper to identify config alias commands
  • Filter config aliases from printAvailableCommands() and calculateMaxCommandWidth()
  • Add printConfigAliases() function to render aliases in dedicated section
  • Comprehensive unit tests for new functionality

Summary by CodeRabbit

  • New Features

    • Help output now shows configuration aliases in a dedicated "ALIASES" section for clearer discovery.
    • Alias commands are marked as config aliases and run as direct subprocesses, preserving their original exit status.
    • Help snapshots now include a telemetry notice banner with opt-out info.
  • Bug Fixes

    • Improved alias execution to reliably surface underlying command exit codes.
  • Tests

    • Added tests and updated snapshots to validate alias handling and help rendering.

✏️ Tip: You can customize this high-level summary in your review settings.

@osterman osterman requested a review from a team as a code owner December 12, 2025 23:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 12, 2025

📝 Walkthrough

Walkthrough

Adds annotation-based config alias support and switches alias execution to direct os/exec invocation; config aliases are excluded from normal command listings and rendered in a new ALIASES help section. Tests and golden snapshots updated to cover the new help output and telemetry banner.

Changes

Cohort / File(s) Summary
Alias execution & annotation
cmd/cmd_utils.go
Alias commands now receive an Annotations["configAlias"] entry and execute by invoking the current executable via os/exec with built args/env; preserves subprocess exit codes and retains existing error handling.
Help rendering for config aliases
cmd/help_template.go
Adds isConfigAlias, getConfigAliases, and printConfigAliases; excludes config aliases from normal width calculation/listing and renders them in a separate ALIASES section integrated into help output.
Help tests
cmd/help_template_test.go, cmd/cmd_utils_test.go
Adds unit tests: TestPrintConfigAliases, TestIsConfigAlias, and multiple processCommandAliases tests validating alias creation, annotations, and non-top-level behavior.
Golden snapshots
tests/snapshots/...TestCLICommands_atmos_--help_config_aliases_section.*, tests/snapshots/...config_alias_tp_--help_shows_terraform_plan_help.*, tests/snapshots/...config_alias_tr_--help_shows_terraform_help.*
Adds/updates stdout and stderr golden files for help output including the new ALIASES section and a telemetry notice banner.
Help/usage test cases
tests/test-cases/help-and-usage.yaml
Adds three (duplicated later to six) help-and-usage test cases covering atmos --help config aliases and config alias tp/tr help invocations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay attention to: cmd/cmd_utils.go alias execution path (arg/env filtering, working dir, stdio wiring, exit-code preservation).
  • Validate cmd/help_template.go integration for width calculations, ordering, Markdown rendering, and that non-alias commands are unaffected.
  • Review new unit tests and golden snapshots for correctness and potential flakiness; check duplicated test-case entries in tests/test-cases/help-and-usage.yaml.

Suggested labels

minor

Suggested reviewers

  • osterman

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a separate ALIASES section in help output to display CLI config aliases, which is the primary focus across multiple modified files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/cli-alias-help-display

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a3d852e and 917d4e5.

📒 Files selected for processing (1)
  • cmd/cmd_utils_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/cmd_utils_test.go
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Acceptance Tests (windows)
  • GitHub Check: Summary

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the size/m Medium size PR label Dec 12, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 12, 2025

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@osterman osterman added the patch A minor, backward compatible change label Dec 12, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 68.08511% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.33%. Comparing base (93d2e6b) to head (917d4e5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/cmd_utils.go 17.64% 14 Missing ⚠️
cmd/help_template.go 96.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1867   +/-   ##
=======================================
  Coverage   73.33%   73.33%           
=======================================
  Files         563      563           
  Lines       54217    54258   +41     
=======================================
+ Hits        39760    39792   +32     
- Misses      11601    11612   +11     
+ Partials     2856     2854    -2     
Flag Coverage Δ
unittests 73.33% <68.08%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
cmd/help_template.go 77.32% <96.66%> (+1.58%) ⬆️
cmd/cmd_utils.go 55.69% <17.64%> (-0.68%) ⬇️

... and 3 files with indirect coverage changes

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

@github-actions github-actions bot added size/l Large size PR and removed size/m Medium size PR labels Dec 13, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 13, 2025
osterman and others added 4 commits December 12, 2025 22:11
CLI aliases defined in atmos.yaml config now appear in a dedicated "ALIASES"
section in --help output instead of being mixed with regular commands in
"AVAILABLE COMMANDS". This improves help clarity by distinguishing between
built-in commands and user-defined shortcuts.

Implementation:
- Mark config aliases with "configAlias" annotation in processCommandAliases()
- Add isConfigAlias() helper to identify config alias commands
- Add getConfigAliases() to retrieve all config aliases
- Add printConfigAliases() to render aliases in dedicated section
- Filter config aliases from calculateMaxCommandWidth() and printAvailableCommands()
- Add comprehensive unit tests for alias help rendering

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add CLI integration test that validates config aliases appear in the
dedicated "ALIASES" section of `atmos --help` output when running from
a project with aliases defined in atmos.yaml.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add integration tests validating config aliases work correctly:
- tp alias executes terraform plan --help correctly
- tr alias executes terraform --help correctly

These tests ensure config aliases properly delegate to their target commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace shell execution with direct process execution (exec.Command) for
CLI alias handling. The shell interpreter (mvdan.cc/sh) was misinterpreting
Windows backslash paths as escape sequences, causing exit code 127 errors.

Direct execution avoids path escaping issues, provides better performance,
and correctly propagates exit codes from aliased commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@osterman osterman force-pushed the osterman/cli-alias-help-display branch from 3ac5fe7 to 982686a Compare December 13, 2025 04:12
@github-actions github-actions bot added size/xl Extra large size PR and removed size/l Large size PR labels Dec 13, 2025
@mergify
Copy link
Copy Markdown

mergify bot commented Dec 13, 2025

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.
Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 13, 2025
The tests were failing in CI because the alias names used (tp, ta, td)
could conflict with existing commands registered to global RootCmd.

The processCommandAliases function internally checks getTopLevelCommands()
which reads from the global RootCmd, not the test's local parentCmd.
When running the full test suite, other tests may register commands
that conflict with the short alias names.

Changed to use unique alias names like "test-alias-tp" that won't
conflict with any existing RootCmd commands.

Also fixed TestProcessCommandAliases_DoesNotOverrideExistingCommands
to properly test the actual behavior: verifying that aliases aren't
added when they conflict with existing RootCmd commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@aknysh aknysh merged commit 4bb3135 into main Dec 14, 2025
56 checks passed
@aknysh aknysh deleted the osterman/cli-alias-help-display branch December 14, 2025 00:16
@github-actions
Copy link
Copy Markdown

These changes were released in v1.202.0-rc.1.

@github-actions
Copy link
Copy Markdown

These changes were released in v1.203.0-test.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/xl Extra large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants