Skip to content

Conversation

@MihalyToth20
Copy link
Collaborator

@MihalyToth20 MihalyToth20 commented Nov 9, 2025

Summary by CodeRabbit

  • Chores

    • Added a patch changeset entry.
    • Applied refined help styling across all CLI commands for easier skimming and clearer command grouping.
  • New Features

    • Added green and bold-green color options to enhance CLI output presentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 9, 2025

Warning

Rate limit exceeded

@MihalyToth20 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed21c0 and ac2fff6.

📒 Files selected for processing (1)
  • packages/cli/src/utils/commands/main-program-utils.ts (2 hunks)

Walkthrough

Inline help formatting was extracted from program.ts into a new public helper applyCustomHelpToAllCommands; custom formatters for root and non-root commands were implemented. New color utilities green and boldGreen were added to the font helpers. Exports were updated to expose the new helper and hide the previous leaf-collection export.

Changes

Cohort / File(s) Change Summary
Changeset
\.changeset/modern-carpets-lose.md
Adds a new changeset entry for @calycode/cli indicating a patch release with message "help command styling for easy skimming."
Program wiring
packages/cli/src/program.ts
Removes inline program.configureHelp(...) and instead imports and invokes applyCustomHelpToAllCommands(program); minor formatting adjustments.
Help formatting utilities
packages/cli/src/utils/commands/main-program-utils.ts
Adds applyCustomHelpToAllCommands(cmd) (exported) and internal customFormatHelpForRoot / customFormatHelp; stops exporting collectVisibleLeafCommands; retains getFullCommandPath; adds font import and new formatted grouping logic for root help.
Color utilities
packages/cli/src/utils/methods/font.ts
Adds green color constant and boldGreen combo; extends font.color and font.combo with these variants.

Sequence Diagram(s)

sequenceDiagram
    participant Program
    participant Utils as main-program-utils
    participant FormatterRoot as customFormatHelpForRoot
    participant FormatterCmd as customFormatHelp
    participant Output as CLI

    Program->>Utils: applyCustomHelpToAllCommands(program)
    activate Utils
    Utils->>Utils: iterate commands & subcommands
    alt command is root
        Utils->>FormatterRoot: assign root formatHelp
        activate FormatterRoot
        FormatterRoot-->>Utils: configured root formatter
        deactivate FormatterRoot
    else non-root
        Utils->>FormatterCmd: assign per-command formatHelp
        activate FormatterCmd
        FormatterCmd-->>Utils: configured command formatter
        deactivate FormatterCmd
    end
    Utils-->>Program: all formatters applied
    deactivate Utils
    Program->>Output: render styled help
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review focus:
    • Recursive traversal and correctness of applyCustomHelpToAllCommands
    • Grouping, mapping, and rendering logic in customFormatHelpForRoot
    • Section assembly and edge cases in customFormatHelp (arguments/options/subcommands)
    • ANSI/color helper additions (green, boldGreen) and their usage
    • Export changes (removal of collectVisibleLeafCommands) and any callers

Poem

🐰 I hopped through code with careful paws,
I painted help in leafy draws,
Green banners wink, bold lines align,
Commands now bloom in tidy sign,
A sprightly CLI, neat as claws. 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 'chore: help formatting improvements' directly aligns with the main changes: refactoring help command styling through a new public API (applyCustomHelpToAllCommands) and adding font styling utilities.

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/cli/src/utils/commands/main-program-utils.ts (2)

22-45: Consider using the top-level isDeprecated function.

Line 23 redefines isDeprecated locally, shadowing the top-level function defined on lines 3-6. For consistency and to avoid confusion, consider using the top-level function instead.

Apply this diff to use the top-level function:

 function collectVisibleLeafCommands(cmd, parentPath = []) {
-   const isDeprecated = (c) => c.description && c.description().trim().startsWith('[DEPRECATED]');
    const path = [...parentPath, cmd.name()].filter((segment) => segment !== 'xano');
    let results = [];

91-91: Consider accepting the helper parameter for consistency.

While customFormatHelpForRoot doesn't currently use the helper, Commander.js's formatHelp signature is (cmd, helper) => string. For consistency with customFormatHelp (line 47) and to follow the framework convention, consider accepting the helper parameter even if unused.

Apply this diff:

-function customFormatHelpForRoot(cmd) {
+function customFormatHelpForRoot(cmd, helper) {
    // 1. Collect all visible leaf commands with their full paths
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5ad250 and da63b16.

📒 Files selected for processing (4)
  • .changeset/modern-carpets-lose.md (1 hunks)
  • packages/cli/src/program.ts (3 hunks)
  • packages/cli/src/utils/commands/main-program-utils.ts (2 hunks)
  • packages/cli/src/utils/methods/font.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/cli/src/utils/commands/main-program-utils.ts (1)
packages/cli/src/utils/methods/font.ts (1)
  • font (36-36)
🪛 LanguageTool
.changeset/modern-carpets-lose.md

[grammar] ~5-~5: Ensure spelling is correct
Context: ...- chore: help command styling for easy scimming

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (7)
packages/cli/src/utils/methods/font.ts (2)

10-10: LGTM!

The green color variant is correctly implemented using the standard ANSI escape code.


17-17: LGTM!

The boldGreen combo and its integration into the font object follow the existing pattern correctly.

Also applies to: 25-25, 32-32

packages/cli/src/program.ts (2)

16-19: LGTM!

The updated imports correctly include the new applyCustomHelpToAllCommands utility for the refactored help formatting.


101-101: LGTM!

Replacing the inline help formatter configuration with the extracted applyCustomHelpToAllCommands utility improves code organization and reusability.

packages/cli/src/utils/commands/main-program-utils.ts (3)

47-89: LGTM!

The custom help formatter for non-root commands is well-structured with clear sections (description, usage, arguments, options, subcommands, footer) and appropriate styling using the font utilities.


187-197: LGTM!

The recursive application of custom help formatters is correctly implemented, distinguishing between root commands (using customFormatHelpForRoot) and subcommands (using customFormatHelp).


199-199: LGTM!

The updated exports correctly expose the new public API applyCustomHelpToAllCommands while keeping collectVisibleLeafCommands as an internal helper.

MihalyToth20 and others added 2 commits November 9, 2025 10:35
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/utils/commands/main-program-utils.ts (1)

3-6: Remove unused function.

The outer isDeprecated function is never used because collectVisibleLeafCommands defines its own version at line 23. This is dead code that should be removed to reduce confusion.

Apply this diff:

-function isDeprecated(cmd) {
-   const desc = cmd.description ? cmd.description() : '';
-   return desc.trim().startsWith('[DEPRECATED]');
-}
-
 function getFullCommandPath(cmd) {
♻️ Duplicate comments (1)
packages/cli/src/utils/commands/main-program-utils.ts (1)

101-140: Previous duplicate "Other:" group concern has been resolved.

The static "Other:" group mentioned in the previous review has been removed. The current implementation only uses the dynamic "Other:" group (lines 135-140) to collect ungrouped commands, which correctly prevents duplication.

🧹 Nitpick comments (1)
packages/cli/src/utils/commands/main-program-utils.ts (1)

152-155: Consider dynamically listing options.

The options are hardcoded rather than using helper.visibleOptions(cmd) to dynamically list registered options. While -v, --version and -h, --help are standard, using the helper would be more maintainable if options change.

If you want to use the helper dynamically:

-   output.push(font.weight.bold('Options:'));
-   output.push(
-      `  -v, --version   ${font.color.gray('output the version number')}\n` +
-         `  -h, --help      ${font.color.gray('display help for command')}\n`
-   );
+   output.push(font.weight.bold('Options:'));
+   const optionsList = helper.visibleOptions(cmd);
+   for (const opt of optionsList) {
+      output.push(`  ${font.color.cyan(opt.flags)}` + `\n    ${opt.description || ''}\n`);
+   }

Note: This function signature currently doesn't receive helper as a parameter, so you'd need to update the function signature to customFormatHelpForRoot(cmd, helper) and the caller at line 185.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3f0e3d and af5bc06.

📒 Files selected for processing (1)
  • packages/cli/src/utils/commands/main-program-utils.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/cli/src/utils/commands/main-program-utils.ts (1)
packages/cli/src/utils/methods/font.ts (1)
  • font (36-36)
🔇 Additional comments (4)
packages/cli/src/utils/commands/main-program-utils.ts (4)

1-2: LGTM!

The font import is necessary for the new custom help formatting functions and is correctly structured.


22-45: Note: Function shadowing will be resolved.

This function redefines isDeprecated at line 23, which shadows the unused outer function at line 3. Once the outer function is removed (as suggested in the previous comment), this shadowing issue will be resolved.


47-89: LGTM!

The custom help formatter for non-root commands is well-structured with clear sections (Banner, Usage, Arguments, Options, Subcommands, Footer) and consistent styling using the font utilities.


195-195: LGTM!

The export change correctly exposes the new public API applyCustomHelpToAllCommands while keeping getFullCommandPath. The previous collectVisibleLeafCommands is now internal-only, which aligns with the refactoring objectives.

@MihalyToth20 MihalyToth20 merged commit 1561a6f into main Nov 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants